Skip to content

Category Archives: Python-Quizzes

Question 13: What is the output of the following program? print ('C:\\inside C directory') (A) C:\inside C directory (B) C:\\inside C directory (C) inside C… Read More
Question 12: What is the output of the following program? var1 = 'Geeks'    print(var1[:4] + 'for' + 'Geeks')  (A) GeeksforGeeks (B) GeekforGeek (C) GeekforGeeks… Read More
Question 11: What is the output of the following program? var1 = 'Hello Geeks!'     var2 = "GeeksforGeeks"    print ( var1[0], var2[1:5]) (A) H eeks… Read More
Question 10: What is the output of the following program? x = 123 for i in x:      print(i, end=" ")  (A) 1 2 3 (B)… Read More
Question 9: What is the output of the following program? my_string = 'geeksforgeeks' for i in range(len(my_string)):      print (my_string, end=" ")      my_string = 'a' (A)… Read More
Question 8: What is the output of the following program? my_string = 'geeksforgeeks' for i in range(len(my_string)):      my_string[i].upper()  print (my_string)  (A) GEEKSFORGEEKS (B) geeksforgeeks (C)… Read More
Question 7: What is the output of the following program? my_string = 'geeksforgeeks' for i in range(my_string):      print(i)  (A) 0 1 2 3 … 12… Read More
Question 6: What is the output of the following program? my_string = "geeksforgeeks" i = "i" while i in my_string:      print(i, end =" ")  (A)… Read More
Question 5: What is the output of the following program? import string    Line1 = "And Then There Were None" Line2 = "Famous In Love"… Read More
Question 4: What is the output of the following program? line = "What will have so will" L = line.split('a')  for i in L:      print(i,… Read More
Question 3: What is the output of the following program? line = "I'll come by then." eline = ""  for i in line:      eline +=… Read More
Question 2: What is the output of the following program? a = 2 b = '3.77' c = -8 str1 = '{0:.4f} {0:3d} {2} {1}'.format(a,… Read More
Question 1: What is the output of the following program? str1 = '{2}, {1} and {0}'.format('a', 'b', 'c')  str2 = '{0}{1}{0}'.format('abra', 'cad')  print(str1, str2)  (A)… Read More
Question 25:Find the output of the following program: counter = {}     def addToCounter(country):      if country in counter:          counter[country] += 1     else:          counter[country] = 1… Read More
Question 24:Find the output of the following program: dictionary = {1:'1', 2:'2', 3:'3'}  del dictionary[1]  dictionary[1] = '10' del dictionary[2]  print (len(dictionary) ) (A) 1… Read More