You are on page 1of 2

PYTHON ASSIGNMENT 1

CLASS XII CS
Q1. Find the output
i. p=5/2 ii. iii. iv. v.
q=p*4 p=10 a=(2+3)**3-6/2 name='Neeru' a,b,c=10,20,30
r=p+q q=20 b=(2+3)*5//4+(4+6)/2 age=21 p,q,r=c-5,a+3,b-4
p+=p+q+r p*=q//3 c=12+(3*4-6)/3 print(name,"you are", age," now print(‘p ,q and r: ‘,p,q,r)
q-=p+q*r q+=p+q**2 d=12%5*3+(2*6)//4 but",)
print(p,q,r) print(p,q) print(a,b,c,d) print("you will be ", age+1," next
ans(27.5 - ans(60 480) ans(122.0 11.0 14.0 9) year")
142.5 12.5)

vi. vii. viii. ix. x.


a=10 x,y=10,20 print("welcome",print("great x=45,200 m=int(input("enter
x,x=a*10,a//2 x,y=x+y,y-x India"),"to our Counter") print(x) num")) ** 2
print(x+1) print(x,y) ans print(x[0],x[1]) print(m)
ans(6) ans(30 10) great India ans a=2**3**2
welcome None to our (45, 200) print(a)
Counter 45 200 (It works from right to
If comma separated value then left ans-512)
tuple create

xi. xii.
a=10 c=65
b=3 print(chr(c))
c=int(a/b) print(chr(c+1))
d=float(a//b) print(chr(c+2))
print(c,d) ans
ans(3 3.0) A
B
C
Q2. Write Python expressions:- Q3. What is the problem in the code:-
i. ii. iii. a + a+2 i. Ii.
a+b 32+93 b Name=”Prateek” a=3
2 2 Age=26 S=A=10
Print(Your name & age are”,Name+age) A=”New”
Q=A/10

Q4. Define indentation.


Q5. Define string types.

Q6. Count the number of bytes for different strings


i. ii. #simple letter size : 1
print(len(“Hello\n Fine”)) print(len('''How\ #Non Graphic char size : 1
are\n # \ symbol no size
you\n''')) #ans is 13 #\n :for carriage return which size is also : 1

Check these concept also:-


 -10/3
 -10//3
 10/3
 10.5//3
 10.5/3
Q7. Find the output:-
i. ii. iii.
b=9 a,d=20,0 x,y,n=10,5,8
a=8 g=”” if(x+y*7 > x+y*n):
if(a>b): if(g=='F'or g=='f'): print(x+y*7)
a=a+5 if(a>50): else:
a=a+2 d=2000*10/100 print(x+y*n)
print(a) else:
d=2000*8/100 ans-50
print(d)

Find the value of d


1. g is f ans-160.0
2. g is m ans-0
Q8. Write a program in Java to accept monthly slary from the user, Q10. Identify the invalid name. State the reason if
find and display income tax with the halp of following rules: invalid.
Monthly salary income tax i. 3name, ii. total amt iii. IF iv. A1
19000 or more 40%
Q11. Datatypes of variables
13500-18999 30%
i. Marks of students
13499 or less 20% ii. Grade of students(‘A’,’B’,’C’)
Q9. Display fee for dance course as:- Q12. First_name=”Ayana”
Rs. 600 for children aged 6-10 i. What is the datatype of First_name.
Rs. 1000 for children aged 11-16 ii. Is 325 the same as “321” ?give reason.
For other then age an error message “Not Eligible”
Q13. Write comments using another way & explain about
both comments type.

#this is comment spreading


#over two lines

Q14. iii. Q15. Sum the series:-


i. j=0
i)1+2+3+4+5…..n
m,n=1,0; for i in range(10,51,10):
for m in range(1,16): j=i/2 ii)2+4+6+8……n
if(m%5==0): print(int(j),end=' ') iii)5+10+15…..n
n+=5
print("n is",n," and m is", m) iv)22+ 42+ 62…n
v)11+22-33+44….n
ii. iv. vi 1+1 + 1 + 1 + 1
sp=10 print(0) 2 3 4 5
for r in range(1, 11): for i in range(1,4): vii) Fibonacci series
for s in range(1, sp): for j in range(1,i+2): viii)From 1-20 series display
print(end=" ") print(2**i, end=" ") prime numbers.
for c in range(1, r+1): print(end ="\n")
print("*"*2, end=" ")
sp-=1
print()

Q16.While loop(WAP) Q17.


i.digit reverse(check palindrome ) y,x,p=3,5,0
ii.digit sum. while(y>0):
iii.armstrong number p=p+x
y=y-1
print(y,x,p)
ans-0 5 15

You might also like