Image

Anyone Can Code.





Image


Tutorial 2: Quiz 2



Kriish Mehta



Question 1: What method is used to find the real value of a complex number?



Question 2: What is the output of the following code?


  x = 17 + 37j
  print(x.imag)



Question 3: What is the output of the following code?


  num1 = '1'
  num2 = '7'
  print(num1 + num2)



Question 4: Write the print statement to print out 'qprogramming' from the following list using indexes


  list_name = ['hello', 'welcome', 'to', 'qprogramming']



Question 5: Convert the following list to a tuple


  list_1 = ['convert', 'to', 'tuple']



Question 6: Add the name 'Ronaldo' to the following set


  footballers = {'Messi', 'Lewandowski', 'Neymar'}



Question 7: What would be the output of the following code? (Output should be typed alphabetically)


  set1 = {'A', 'E', 'I'}
  set2= {'A', 'E', 'I', 'O', 'U'}
  set1.update(set2)
  print(set1)



Question 8: Write the print statement to print out the length of the following list


  list2 = ['length', 'item2', '3']



Question 9: What would be the output of the following code?


  set1 = {1, 2, '3', 4, 5}
  set2 = {1, '2', 3, '4', '5'}
  set3 = set1.intersection(set2)
  print(set3)



Question 10: Which method is used to delete the last item of a set? (Enter method name with the correct syntax)



Question 11: Which method is used to delete all items from a set? (Enter method name with the correct syntax)



Question 12: What is the name of the datatype used to define something which has no value at all? (Hint: It is its own data type)



Question 13: True or False: Dictionaries are mutable while tuples are not.



Question 14: What is the output of the following code?


  dict = {'name': 'Leo', 'age': '17', 'type': 'name'}
  print(dict['name'])



Question 15: Write a print statement to print out the type of the following. After writing the code use a comma and then write what you think the type is


  x = (3, 6, 7, [20, 1, 3, True])







Score =




Copyright © 2020, Q-Programming | Created by Arjun Sodhi, Balpreet Juneja and Sammarth Kumar | Developed and Designed by Sammarth Kumar