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

Question Patterns

Uploaded by

spartanicpratham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Question Patterns

Uploaded by

spartanicpratham
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Practice Question Bank & Mid-Term Examination 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)

2. Write Each statement below is either TRUE or FALSE.

i. In computer science, algorithm refers to a special method usable by a


computer for the solution to a problem.
ii. Any algorithm is a program.
iii. Python is case sensitive when dealing with identifiers.
iv. Mathematical operations can be performed on a string.
v. Addition and Subtraction has the same precedence level.
vi. The expression int(x) implies that the variable x is converted to integer.
vii. nested if-else are allowed in Python.

3. What do you mean by an Algorithm? What are the characteristics of an Algorithm?


Write an Algorithm to find the factorial of given integer number.
4. Why Python programming language is becoming so popular in programming world?
list the applications of python and explain any one with suitable example.
5. Determine the output:

for i in range (20,30,10):

j=i/2

print(j)

6. What is the output of the following code?

print(bool(0), bool(3.14159), bool(-3), bool(1.0+1j))

7. Actual instructions in flowcharting are represented in __________.

(A) Circles (B) Boxes (C) Arrows (D) Lines

8. To repeat a particular task, we use __________.

(A) Input (B) Loop (C) Output (D) Condition


9. Which of the following is not a keyword in python?

(A) return (B) in (C) False (D) false

10. What is the output of following code?

a=set('abc')

b=set('cd')

print(a^b)

11. How do Mutable data types differ from Immutable data types? Briefly discuss the

syntax and utility of the following data types in python:

(i) Lists

(ii) Tuples

(iii) Dictionaries

12. Compare Break and Continue statement, illustrate the use of both statements

through a suitable code in python.

13. Draw flow chart and write algorithm to print Fibonacci series upto the number of

terms entered by the user.

14. Write a program in python to generate the following pattern

**

***

****

15. Write program in python to perform following:

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.

17. What is Indentation? Explain with example.

18. Describe an algorithm for the following

i) Prime number or not

ii) Odd or even

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

underline the correction; ‐

i. x= int(“Enter value of x:”)


for in range [0,10]:
if x=y
print( x + y)
else:
print( x‐y)

ii. a, b = 0
if (a = b)
a +b = c
print(c)

iii. 250 = Number


WHILE Number<=1000:
if Number=>750
print (Number)
Number=Number+100
else
print( Number*2)
Number=Number+50

iv. 25=Val
for I in the range(0,Val)
if I%2==0:
print( I+1)
Else:
print (I‐1

v. a=int(input("ENTER FIRST NUMBER"))


b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)

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

22. Find output generated by the following code:

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)

iii. for a in range(3,10,3):


for b in range(1,a,2):
print(b, end='')
print( )

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)

viii. x="hello world"


print(x[:2],x[:-2],x[-2:])
print(x[6],x[2:4])
print(x[2:-3],x[-4:-2])

ix. print(" ' " ' " " ' " ' ")
x. print(123,"\nabc")

xi. temp=input("enter a number")


x=(temp)*0
y=int(temp)*0
z=bool(temp*0)
print(y)
print(x)
print(z)

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.

27. Explain following 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.

29. Explain while loop with suitable example?

30. Explain for loop with suitable example?

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)

34. Explain input command in python with suitable example.

35. Explain print command in python with suitable example

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)

37. Explain automated memory management process in python.

You might also like