Вы находитесь на странице: 1из 8

Q1. A statement that appears in the code and but does nothing.

a) Token b) Lexical unit c) Empty statement d) Coercion


Q2. Name given by user for a part of a program.
a) Token b) Keyword c) Constant d) identifier

Q3. See the Python string declaration below ?

myschool="kv fort william"

Write the output of myschool[::-2]

Q4. Write the output of the following python code:

x="apple,pear,peach"

y=x.split(",")

for z in y:

print( z.count(‘p’) , end=”&”)

Q5. Which of the following is not a Relational operator?

a. ==

b. !=

c. =

d. >

Q6. The keys of a dictionary must be of immutable type?

True / False

Q7. Identify the valid bitwise operator in Python from the following.

a) << b) < c) ** d) and

Q8. Write the type of tokens from the following :

a) For

b) Num

Q9. A Dictionary is declared in Python as below mydi={1:2,3:4}

Identify the method that will be used to display all (i) keys (ii) values

Q10. Which operator is used in python to import all modules from package?
a) .Operator b) ->Symbol c) *Operator d) ,Operator

Q11. Find and write the output of the following python code(if errors means correct it):

L = ["X",20,"Y",10,"Z",30]

CNT = 0

ST = ""

INC = 0

for C in range(1,6,2):

CNT= CNT + C

ST= ST + L[C-1] + "@"

INC = INC + L[C]

print(CNT, INC, ST)

Q12. Predict the output of the following code snippets?

i.

arr = [1, 2, 3, 4, 5, 6]

for i in range(1, 6):

arr[i - 1] = arr[i]

for i in range(0, 6):

print(arr[i], end = " ")

ii.

Numbers = [9, 18, 27, 36]

for Num in Numbers :

for N in range(1, Num%8) :

print(N, "#", end = " ")

print( )

Q13. Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.

Num = input("Number:")

Sum = 0
for i in range(10,Num,3)

Sum+=i

if i%2=0:

print ( i*2)

Else:

print ( i*3 print Sum)

Q14. Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[-2 : -5 : -1])

Q15. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect? a)
print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T)

Q16. Name the function / method required for

(i) Finding second occurrence of m in ‘madam’


(ii) Get position of an item in list

Q17. Find the all possible output :

Q18. Suppose a Tuple is declared as follows mytup=(34,54,67,89) Which of the following


declaration(s) is valid and will not give any error?

a. mytup.index(67)

b. mytup.index(0)

c. mytup.index(89)

d. mytup.index(2)

Q19. Which of the following is an invalid statement?

a. a, b, c = 1000, 2000, 3000


b. a = b = c = 1,000,000

c. abc = 1,000,000

d. a b c = 1000, 2000, 3000

Q19. Suppose a tuple T is declared as T = (10, 20, 40, 80, 20) Write the output of the following code?
i. print(T[1])

ii. print(count(20))

iii. print(max(T))

iv. print(len(T))

Q20. What would follow expression return?

“hello world”.isalnum()

Q21. What is the role of these functions? i) lstrip() ii) capitalize()

Q22. What will be the output of the following code?

A = ‘7’

print(A*4+str(int(A)*2))

Q23. Predict output of the following code:

A=[12,45,78,45,234] B=len(A)

for i in range(0,B,2):

print(i)

Q24.Which of the following are not valid operations in python? i. Slicing a list ii. Concatenation of a
list and a tuple iii. Slicing a dictionary iv. Adding an element to an existing tuple.

Q25. Consider python statement :

X=eval(input(“Enter data”))

What will be the data type of X if the user input is:

i) [1,3,53]
ii) 45

26. List are ______________. Tuples are _____________ sequence.

(Mutable / Immutable)

Q27. Predict the output of the following:


x, y = 7, 12

x, y, x = x+4, y+2, x+12

print (x, y)

Q28. Boolean expression Y+YZ =?

(i) Y (ii) Z (iii) 1 (iv) 0

Q29. 2’s compliment of 1010 is

(i) 110 (ii) 1111 (iii) 1010 (iv) 0

Q30.

Q31. What is the output?

a=5

if x:

print (“Good”)

else:

print(“By”)

Q32. What will be the output of Python code?

str1="6/4"

print("str1")

Q33. Which of the following will give "Simon" as output?


If str1="John,Simon,Aryan"

(i) print(str1[-7:-12])
(ii) print(str1[-11:-7])
(iii) print(str1[-11:-6])
(iv) print(str1[-7:-11])

Q34 Which of the following creates a tuple?

(i) tuple1=("a","b")
(ii) tuple1[2]=("a","b")
(iii) tuple1=(5)*2
(iv) None of the above

Q35. The record of a student (Name, Roll No., Marks in five subjects and percentage of marks) is
stored in the following list:

stRecord = ['Raman','A-36',[56,98,99,72,69], 78.8]

Q36 Write Python statements to retrieve the following information from the list stRecord.

(a) Percentage of the student

(b) Marks in the fifth subject

(c) Maximum marks of the studen

(d) Roll no. of the student

(e) Change the name of the student from ‘Raman’ to ‘Raghav’

Q37 Predict the output of following code snippet:

(i)

x, y=20,60

y, x, y=x, y-10, x+10

print(x, y)

(ii)

a, b=12,13

c, b=a*2,a/2

print(a, b, c)

Q38. Find and write the output of the following Python program code :

>>>print (3**2 + 18/9 - 3**4+1)

>>>print (12%5*3+(2*6) // 4)
Q39. Name the law shown below and verify it using a truth table.

A + B.C=(A+B).(A+C)

Q40. Consider the following string mySubject:

mySubject = "Computer Science"

What will be the output of the following string operations :

A. print(mySubject[0:len(mySubject)])

B. print(mySubject[-7:-1])

C. print(mySubject[::2])

D. print(mySubject[len(mySubject)-1])

E. print(2*mySubject)

F. print(mySubject[::-2])

Q41 Find the output of the following

Text=”gmail@com”

L=len(Text) ntext=””

for i in range (0,L):

if text[i].isupper():

ntext=ntext+text[i].lower()

elif text[i].isalpha():

ntext=ntext+text[i].upper()

else:

ntext=ntext+’bb’

print(ntext)

Q42.
Q43. Write a Python program to calculate the compound interest. The principal, rate of interest and
time must be entered by the user. (Formula: Compound Interest = Principal (1 + Rate/100) Time )

Q44. Write a program that creates a GK quiz consisting of any five questions of your choice. The
questions should be displayed randomly. Create a user defined function score() to calculate the
score of the quiz and another user defined function remark (score value) that accepts the final score
to display remarks as follows:

Q45. Program to find prime numbers between 2 to 50 using nested for loops. OR Write a function
that checks whether an input number is a palindrome or not. [Note: A number or a string is called
palindrome if it appears same when written in reverse order also. Forexample, 12321 is a
palindrome while 123421 is not a palindrome]

Вам также может понравиться