Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Practical File waale code.pdf
1. Enter first number: 5
Enter second number: 5
10.0 is the sum
0.0 is the difference
25.0 is the multiplication
1.0 is the division
3125.0 is the exponent
In [1]: #1Compute sum, subtraction, multiplication, division and exponent of given variables input by the user.
a=float(input('Enter first number: '))
b=float(input('Enter second number: '))
c=a+b
d=a-b
e=a*b
f=a/b
g=a**b
print(c,"is the sum")
print(d,"is the difference")
print(e,"is the multiplication")
print(f,"is the division")
print(g,"is the exponent")
In [2]: #Compute area of following shapes: circle, rectangle, triangle, square, trapezoid and parallelogram.
#Area of circle
radius=5
pi=3.14
areac=pi*radius*radius
print("area of circle:",areac)
#Area of rectangle
length=20
breadth=35
arear=length*breadth
print("area of rectangle:",arear)
#Area of triangle
base=30
height=10
areat=base*height/2
print("area of triangle:",areat)
2. area of circle: 78.5
area of rectangle: 700
area of triangle: 150.0
area of square: 16
area of trapezoid: 112.5
area of parallelogram: 450
#Area of square
side=4
areas=side*side
print("area of square:",areas)
#Area of trapezoid
b1=10 #here x is base1 of trapezoid
b2=35 #here y is base2 of trapezoid
h1=5 #here h is height of trapezoid
areat=(b1+b2)/2*h1
print("area of trapezoid:",areat)
#Area of parallelogram
base1=10 #here base1 is base of parallelogram
height1=45 #here height is height of parallelogram
areap=base1*height1
print("area of parallelogram:",areap)
In [3]: #Compute volume of following 3D shapes: cube, cylinder, cone and sphere.
#Volume of a cube
scube=float(input('Enter side:'))
vcube=scube*scube*scube
print(vcube,"is the volume of cube")
#Volume of a cylinder
pi=3.14
rcyl=float(input('Enter radius of cylinder:'))
hcyl=float(input('Enter height of cylinder'))
vcyl=pi*rcyl*rcyl*hcyl
print(vcyl,"is the volume of cylinder")
#Volume of cone
pi=3.14
rco=float(input('Enter the radius of cone:'))
hco=float(input('Enter the height of cone:'))
vco=(pi*rco*rco*hco)/3
3. Enter side:5
125.0 is the volume of cube
Enter radius of cylinder:10
Enter height of cylinder5
1570.0 is the volume of cylinder
Enter the radius of cone:4
Enter the height of cone:6
100.48 is the volume of the cone
Enter the radius of sphere:122
7602350.293333333 is the volume of sphere
print(vco,"is the volume of the cone")
#Volume of sphere
pi=3.14
rsph=float(input('Enter the radius of sphere:'))
vsph=(4/3)*pi*rsph*rsph*rsph
print(vsph,"is the volume of sphere")
In [4]: #Compute and print roots of quadratic equation ax2+bx+c=0, where the values of a, b, and c are input by the user.
In [5]: #Print numbers up to N which are not divisible by 3, 6, 9,, e.g., 1, 2, 4, 5, 7,...
print("Numbers up to 100")
for number in range(0,101):
if number % 3 !=0 and number % 6 !=0 and number % 9 !=0:
print(number)
5. 65
67
68
70
71
73
74
76
77
79
80
82
83
85
86
88
89
91
92
94
95
97
98
100
Input the lengths of triangle
Enter the first side of triangle: 23
Enter the second side of triangle: 23
Enter the third side of triangle: 45
It is an isosceles triangle
In [6]: #Write a program to determine whether a triangle is isosceles or not?
print("Input the lengths of triangle")
side1=float(input("Enter the first side of triangle: "))
side2=float(input("Enter the second side of triangle: "))
side3=float(input("Enter the third side of triangle: "))
if side1==side2 or side2==side3 or side3==side1:
print("It is an isosceles triangle")
else:
print("error")
In [7]: #Print multiplication table of a number input by the user.
t=int(input("Enter the number of which you want the table :"))
6. Enter the number of which you want the table :12
12 X 0 = 0
12 X 1 = 12
12 X 2 = 24
12 X 3 = 36
12 X 4 = 48
12 X 5 = 60
12 X 6 = 72
12 X 7 = 84
12 X 8 = 96
12 X 9 = 108
12 X 10 = 120
Enter a natural number: 5
The sum is 5
The sum is 9
The sum is 12
The sum is 14
The sum is 15
for numbers in range(0, 11):
print(t,'X',numbers,'=',t*numbers)
In [11]: #Compute sum of natural numbers from one to n number.
natu=int(input('Enter a natural number: '))
if natu<0:
print("Please enter a positive number")
else:
sum=0
while natu>0:
sum+=natu
natu-=1
print("The sum is",sum)
In [10]: #Print Fibonacci series up to n numbers e.g. 0 1 1 2 3 5 8 13…..n
nterms=int(input("Enter number of terms :"))
n1,n2=0,1
count=0
if terms<=0:
print("please enter a positive number")
elif terms==1:
print("Fibonacci seq upto",terms,":")
print(n1)
else:
7. Enter number of terms :12
fibonacci seq :
0
1
1
2
3
5
8
13
21
34
55
89
Enter a natural number: 4
Answer is 1
Answer is 2
Answer is 6
Answer is 24
print("fibonacci seq :")
while count < nterms:
print(n1)
nth=n1+n2
n1=n2
n2=nth
count+=1
In [15]: #Compute factorial of a given number.
natu=int(input('Enter a natural number: '))
factorial=1
if natu<0:
print("Please enter a positive number")
elif natu==0:
print("Answer is 0")
for xx in range(1, natu+1):
factorial=factorial*xx
print("Answer is ",factorial)
In [5]: #Count occurrence of a digit 5 in a given integer number input by the user.
integer=[5,5,5,5,5,5,5]
integer.count(5)