Question Patterns
Question Patterns
1. Rewrite the following code in python after removing all syntax error(s).Underline
each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)
j=i/2
print(j)
a=set('abc')
b=set('cd')
print(a^b)
11. How do Mutable data types differ from Immutable data types? Briefly discuss the
(i) Lists
(ii) Tuples
(iii) Dictionaries
12. Compare Break and Continue statement, illustrate the use of both statements
13. Draw flow chart and write algorithm to print Fibonacci series upto the number of
**
***
****
i) You are an event planner responsible for organizing annual events for a global
company. The company requires you to provide the schedule for the next 10 years,
but for accurate planning, you need to know if each year in the given range is a leap
year or not. A leap year will allow for one extra day in the year (February 29th),
which might impact the event scheduling. Write a Python program that helps you
identify whether a given year is a leap year or not.
ii) Riya is working on a robotics project where she needs to control the movement of a
small robot based on sensor inputs. The sensor returns a number representing the
distance between the robot and an obstacle in front of it. Riya wants to modify the
robot's movement logic based on whether the distance is an odd number or not. She
needs a Python program that checks whether the given distance (a number provided
by the sensor) is odd. If the number is odd, the robot will perform a "right turn"; if
not, it will continue moving straight.
16. Compare flowchart and algorithm. Draw flowchart to find factorial of a number
entered by user.
19. Define Variable and mention rules for choosing names of Variable.
20. Implement the python program to calculate total and average marks based on
input.
21. Find error in the following code (if any) and correct code by rewriting code and
ii. a, b = 0
if (a = b)
a +b = c
print(c)
iv. 25=Val
for I in the range(0,Val)
if I%2==0:
print( I+1)
Else:
print (I‐1
vi. i==1
a=int(input("ENTER FIRST NUMBER"))
FOR i in range[1, 11];
print(a,"*=", i ,"=",a * i)
vii. a=”1”
while a>=10:
print("Value of a=",a)
a=+1
viii. Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
Sum+=1
if i%2=0:
print(i*2)
Else:
print(i*3 print Sum)
ix. weather='raining'
if weather='sunny':
print("wear sunblock")
elif weather='snow':
print("going skiing")
else:
print(weather)
x. x=integer(input('Enter 1 or 10'))
if x==1:
for x in range(1,11)
Print(x)
Else:
for x in range(10,0,‐1):
print(x)
xi. s = 'coder'
print(s[::0])
i. p=10
q=20
p*=q//3
q+=p+q**2
print(p, q)
ii. x=20
x=x+5
x=x-10
print(x)
x, y=x-1,50
print (x, y)
iv. x=10
y=5
for i in range(x-y*2):
print("%",i)
v. x="one"
y="two"
c=0
while c<len(x):
print(x[c],y[c])
c=c+1
vi. for i in range(-1,7,2):
for j in range(3):
print(i,j)
vii. string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]
else:
count+=1
break
print(string)
print(count)
ix. print(" ' " ' " " ' " ' ")
x. print(123,"\nabc")
23. Explain any six arithmetic operators of python with suitable examples of each.
24. Explain any six assignment operators of python with suitable examples of each.
25. Explain all comparison operators of python with suitable examples of each.
26. Explain “and, or, not” operators of python with suitable examples of each.
a. is,
b. in,
c. not in
28. Explain all bitwise operators of python with suitable examples of each.
31. Explain break, continue and pass statement with suitable example of each.
32. Differentiate between List, Tuple & Set with suitable examples of each.
33. What will be the value of variables x, y & z after execution of following python
program.
temp=5
x=temp*0
y=int(temp)*5
z=bool(temp*0)
36. State which of the following python statements are valid and invalid.
a. print("ksk", + "123")
b. print("ksk" '+' "123")
c. print("ksk", '+', "123")
d. print('ABC is a "technological" University')
e. print(2 + '3')
f. print('2' * 3)
g. x = input(2)