0% found this document useful (0 votes)
4 views

assignment-questions-python

The document contains a series of Python programming assignment questions, each requiring a specific task such as converting temperatures, calculating areas, and determining profits or losses. Each question is accompanied by example code and expected output. The assignments cover a range of topics suitable for a Python workshop.

Uploaded by

sanikashinde8998
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

assignment-questions-python

The document contains a series of Python programming assignment questions, each requiring a specific task such as converting temperatures, calculating areas, and determining profits or losses. Each question is accompanied by example code and expected output. The assignments cover a range of topics suitable for a Python workshop.

Uploaded by

sanikashinde8998
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT QUESTIONS (PYTHON Workshop)

1) Write a program to convert Celsius to Fahrenheit temperature.

Code output
c=int(input('enter temperature in celsius:'))
f=c*(9/5)+32
print('%d celsius is %d fahrenheit'%(c,f))

2) Write a program to calculate area and perimeter of circle.

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))

3) Write a program to calculate total bill by adding interest to the bill .

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))

4) Write a program to convert meters to cm , inch, yards.

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)

6) Write a program to check if a character is upper case or lower case.

Code Output
s=(input('enter a single character:'))
if s.islower():
print(s,'is in lower case')
else:
print(s,'is in upper case')

7) Write a program to calculate electricity bill :


 For first 50 units Rs:0.50/unit
 For next 100 units Rs:0.75/unit
 For next 100 units Rs:1.25/unit
 For unit above 250 Rs:1.50/unit
 An additional surcharge of 17% is added to the bill.

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))

9) Write a program to print factorial of a number.

Code Output
x=int(input('enter number:'))
f=1
for i in range(1,x+1):
f=f*i
print(f)

10) Write a program to find sum of digits in a number.

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)

12) Write a program to print reverse of a number.

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)

13) Write a program to print Fibonacci series up to n numbers.

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

You might also like