Image

Anyone Can Code.





Image


Tutorial 4: Quiz 2



Kriish Mehta



Question 1: Write an if statement to check if a variable 'a' is bigger than another variable 'b'.



Question 2: Write an if statement to check if a variable 'a' is less than both variables 'b' and 'c'.



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


    x = 99
    y = -99
    if (x+y) > 0:
        print("Positive")
    elif (x-y) =< 0:
        print("Negative")
    else:
        print(0)



Question 4: Write an if statement to check if a variable 'x' is a negative number.



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


    maths = 69
    physics = 9
    chemistry = 99
    total = maths + physics + chemistry
    if maths < 65 or physics < 55 or chem < 50 and total <= 160:
        print("Fail")
    else:
        print("Pass")



Question 6: True or False: The output of the following code is 'Moderate'


    x = 24
    y = -6
    if y*4 == x:
        print("Easy")
    elif x+y >= x:
        print("Moderate")
    else:
        print("Tough")



Question 7: What is the output of the following code? (If there are two outputs separate them by commas)


    x = 9
    if x > 10.0 or x < 10.0:
        print("Float")
    if x > 8 and x < 10:
        print(x)
    else:
        print("Integer")



Question 8: Fill in the blank: Python evaluates an if/elif/else statement to b______ values (Type the full word)



Question 9: What is the output of the following code if 100 is entered as the units?


    units = int(input("Enter the units consumed: "))
    cost = 75
    if 0 <= units <= 100:
        cost = cost + units*5
    elif 100 < units <= 250:
        cost = cost + 500 + (units-100)*10
    elif units > 250:
        cost = cost + 2000 + (units-250)*20
    print(cost)



Question 10: Write an if statement to check if a variable 'x' is equal to two times a variable 'y' + 1







Score =




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