Sie sind auf Seite 1von 2

8/4/2019 Assignment 1

In [1]: n=int(input("Enter the distance travelled per day ") )


m=int(input("Enter the distance to be travelled ") )
print("Time taken to travel =" , int(m/n),"days")

Enter the distance travelled per day 10


Enter the distance to be travelled 20
Time taken to travel = 2 days

In [2]: n=int(input("Enter e 3 digit number"))


sum=0
if(n>99 and n<1000):
while(n!=0):
sum=(sum+int(n%10))
n=n/10
print("Sum of Digit =",sum)
else:
print("Wrong Input")

Enter e 3 digit number123


Sum of Digit = 6

In [3]: b=int(input("Enter the Base of Right-Angle Triangle "))


p=int(input("Enter the Height of Right-Angle Triangle "))
print("Area of Right-Angle Triangle =",(b*p)/2)

Enter the Base of Right-Angle Triangle 6


Enter the Height of Right-Angle Triangle 8
Area of Right-Angle Triangle = 24.0

In [4]: a=int(input("Enetr the a number "))


b=int(input("Enetr the a number "))
c=int(input("Enetr the a number "))
print("Average =",int((a+b+c)/3))

Enetr the a number 10


Enetr the a number 20
Enetr the a number 30
Average = 20

In [5]: n=int(input("Enter a number to check "))


if(n%2==0):
print(n," is an Even Number")
else:
print(n," is an Odd Number")

Enter a number to check 9


9 is an Odd Number

localhost:8888/nbconvert/html/Assignment 1.ipynb?download=false 1/2


8/4/2019 Assignment 1

In [6]: c=int(input("Enetr temperature in celsius to convert "))


f=(c*(9/5))+32
print("Temperature in Fahrenheit =",f)

Enetr temperature in celsius to convert 1


Temperature in Fahrenheit = 33.8

In [7]: a=int(input("Enetr the a number "))


b=int(input("Enetr the a number "))
c=int(input("Enetr the a number "))
print("Maximum =",max(a,b,c))
print("Minimum =",min(a,b,c))

Enetr the a number 32


Enetr the a number 6
Enetr the a number 78
Maximum = 78
Minimum = 6

In [8]: a=int(5)
b=float(5)
c='5'
print(type(a), a)
print(type(b), b)
print(type(c), c)

<class 'int'> 5
<class 'float'> 5.0
<class 'str'> 5

localhost:8888/nbconvert/html/Assignment 1.ipynb?download=false 2/2

Das könnte Ihnen auch gefallen