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

16-Python Programming

Uploaded by

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

16-Python Programming

Uploaded by

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

QUESTIONS

Session 16
What will be the output
3) age=input()
1) x,y=2,6 print(age *=2)
x,y = y, x+2
4)
print(y) msg="Goodmorning ! Welcome To This Class“
print(x>>2) msg.find(“0”)
msg.capitalize()
2)x=101
5) "sum of 2 and 5“*5
if x%2 = 0:f
print("even number")
else
print("odd number")
6) 8)
total=0 “62” +”4”
for i in range(10,0,-1):
total+=i 9)
print(total) a=150
b=190
7) while (a!=b):
a=b=40 if (a>b):
x=y=50 a=a-b
if a< 100: else:
if b >=50: b = b-a
x +=1 print(a,b)
else:
y +=1
print(x)
print(y)
output
1 )output : 4
1
2) Error
3) Error
4) 1
‘Goodmorning ! welcome to this class’
6) 55
7) 50
51
8)”624”
9)10 10
Output Questions
1. If x=32 and y=16 what will be the value of x and y after following operations:
(i) x <<2
(ii) x ^y
(iii) X&y
2. s=“University of Delhi”
(i) s[:10]+ s[10 :]
(ii) s[0 :len(s)]
(iii) s[0:10:2]
3. math.ceil(7.4)
4. math.floor(7.4)
5. ((not(9==8) and (7+1) !=8)) or(6<4.5)
6. Rewrite the following program using for loop
Total=0
Count=1
While count<5:
Total += count
count+=1
print(Total)
7. What is the output
for i in range(20,30):
if(i% 9 !=0):
continue
print(i)
◦ Write a python program that accepts as input your favorite color as a string. Interchange the first
and last characters of your favorite color and display the resulting string

◦ Using a while loop write a user defined python function to find the sum of all positive numbers
entered by the user. As soon as the user enters a negative number stop taking any further input
from user and display the sum

◦ Write a python function pattern(n) which takes n(0 <n <10) as parameter and prints a pattern like
the one shown below/For eg for n=5
1
12
123
1234
12345

◦ Write a user defined function sumsquares(n) that accepts number n as argument. The function
returns sum of squares of first n numbers. Write a python statement to call the function and print
the result for n=6

You might also like