Image

Anyone Can Code.





Image


Tutorial 4: Quiz 1



Kriish Mehta




Question 1: Which command is used to signify all the other conditions than the one mentioned?



Question 2: Which of the following is the correct syntax of an if statement?



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

  x = 100
  if x % 5 != 0:
    print("Ok")
  elif x % 5 == 0:
    print(x)
  else:
    print("x")



Question 4: How does Python identify different blocks of code with different conditions?



Question 5: Which command can be used to check for more conditions if the previous one is not met?



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

  code = 17
  if code < 10:
      print("Invalid")
  elif code >= 10:
      print("Valid")
  else:
      print(code)
        



Question 7: Which two operators can be used to add requirements for the input?



Question 8: Ron scored 85% in his first term exams. Look at the code below. What grade did Ron get?

  x = 85
  if x >= 90:
      print("A1")
  elif x > 85 and x <= 90:
      print("A2")
  elif x >70 and x <= 85:
      print("B")
  else:
      print("F")



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

  x = 9
  y = 10
  if x >= y or x == y:
      if x == 9:
          print(x)
      else:
          print(y)
  else:
      print(x+y)



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

  name = 'Jonathan'
  if len(name) > 8 and len(name) < 16:
      print("Hi " + name)
  elif len(name) >= 16:
      print("Hello")
  else:
      print("Hello " + name)







Score =




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