assignment-questions-python
assignment-questions-python
Code output
c=int(input('enter temperature in celsius:'))
f=c*(9/5)+32
print('%d celsius is %d fahrenheit'%(c,f))
Code Output
r=int(input('enter radius of circle:'))
pi=3.14
a=pi*(r*r)
p=2*pi*r
print('area of circle is %d and perimeter is
%d'%(a,p))
Code Output
a=int(input('enter amount:'))
i=int(input('enter percentage of interest:'))
t=((i/100)*a)+a
print('total amount with intrest of %d
percentage is %d'%(i,t))
Code Output
m=int(input('enter distance in meters:'))
c=m*100
i=m*39.37
y=m*1.094
print('%d meter is %f centemeter,%f inch
and %f yard'%(m,c,i,y))
5) Write a program to calculate profit and loss. Input is selling price and cost price.
Code Output
n=int(input('enter cost price:'))
n1=int(input('enter selling price:'))
res=n1-n
if res>0:
print('profit of rupees:',res)
else:
print('loss of rupees:',res)
Code Output
s=(input('enter a single character:'))
if s.islower():
print(s,'is in lower case')
else:
print(s,'is in upper case')
Code Output
u=int(input('enter units consumed:'))
us1=25.0
us2=75.0
us3=125.0
if u>250:
bill=u*1.50
elif u<=50:
bill=u*0.50
elif u>50 and u<150:
bill=us1+us2
elif u>50 and U<250:
bill=us1+us2+us3
print('bill before supcharge',bill)
bill=((17/100)*bill)+bill
print('total bill is ',bill)
8) Write a program to calculate salary using basic, DA , HRA.
Code Output
b=int(input('enter basic salary:'))#b-basic
h=(20/100)*b
d=(75/100)*b
if b<10000:
g=d+b
print('gross salary is %d+%d=%d'%
(d,b,g))
elif b>=10000 and b<20000:
h=(50/100)*h
g=d+b+h
print('gross salary is %d+%d+%d=%d'%
(d,b,h,g))
elif b>=20000:
g=b+d+h
print('gross salary is %d+%d=%d'%
(d,b,g))
Code Output
x=int(input('enter number:'))
f=1
for i in range(1,x+1):
f=f*i
print(f)
Code Output
n=int(input('enter number:'))
sum=0
while n!=0:
sum=sum+int(n%10)
n=int(n/10)
print('sum of digits is',sum)
11) Write a program to print odd numbers for 10-30.
Code Output
for i in range(11,31,2):
print(i)
Code Output
n=int(input('enter number:'))
rev=0
while n>0:
rem=n%10
rev=(rev*10)+rem
n=n//10
print("reverse of number is",rev)
Code Output
n1,n2,n3=0,1,0
n=int(input('enter number:'))
print("0\n1")
for i in range(2,n):
n3=n1+n2
print(n3)
n1=n2
n2=n3