Python Quiz for beginners

avatar

Capture.JPG

  • What is the output?

for i in range(10, 25, 3):
print( i, end=', ')

answer - 10, 13, 16, 19, 22,

  • def calculate (num1, num2=4):
    res = num1 * num2
    print(res)

calculate(5, 7)

answer - 35

  • The output is?

salary = 9000

def printSalary():
salary = 11000
print("Salary:", salary)

printSalary();
print("Salary:", salary)

answer - Salary: 11000
Salary: 9000

  • Is a string immutable?
    When we modify a string, Python creates a new one and assigns a new string to a new variable

True or false?

Answer - True

  • Output?
    str = "pynative"
    print (str[1:4])

answer - yna

  • x = 36 / 4 * (7 + 2) * 4 + 3
    print(x)

answer - 327

image -screenshot



0
0
0.000
0 comments