Quiz Space

Python week 3 important questions

Week 3 of Programming in Python: Conditionals (contd.). Extra important questions based on the recent, changing patterns of the exams, from basic to advanced. Practise them in learning mode: each question has a worked solution.

Question 1

One correct option

What is printed by the following program?

a = int(input())
b = int(input())
c = int(input())
if a + b <= c or a + c <= b or b + c <= a:
print("invalid")
elif a == b == c:
print("equilateral")
elif a == b or b == c or a == c:
print("isosceles")
else:
print("scalene")

Input given to the program (one line per input() call):

2
3
9
  1. A

    INVALID

  2. B

    invalid

  3. C

    Error

  4. D

    (nothing)

Question 2

One correct option

What will be the output of the code below?

a = int(input())
b = int(input())
c = int(input())
d = b * b - 4 * a * c
if d > 0:
print("two")
elif d == 0:
print("one")
else:
print("none")

Input given to the program (one line per input() call):

1
1
1
  1. A

    invalid

  2. B

    Error

  3. C

    none

  4. D

    two

Question 3

One correct option

Consider the program given below. What does it print?

w = float(input())
h = float(input())
bmi = w / (h * h)
if bmi < 18.5:
print("under")
elif bmi < 25:
print("normal")
elif bmi < 30:
print("over")
else:
print("obese")

Input given to the program (one line per input() call):

80
1.75
  1. A

    under

  2. B

    over

  3. C

    obese

  4. D

    invalid

More questions in this week

Authorise with Google to see every question with its answer and explanation and practise it in learning mode.