0
0
Pythonprogramming~20 mins

Taking input using input() in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Input Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this code when input is '5'?
Consider the following Python code that takes input and processes it:
Python
num = input("Enter a number: ")
result = int(num) * 2
print(result)
A10
B55
CTypeError
D5
Attempts:
2 left
💡 Hint
Remember that input() returns a string and you need to convert it to an integer before multiplying.
Predict Output
intermediate
2:00remaining
What will be printed if the input is 'hello'?
Look at this code snippet:
Python
user_input = input("Say something: ")
print(user_input * 3)
ATypeError
Bhellohellohello
Chello 3 times with spaces
Dhello3
Attempts:
2 left
💡 Hint
Multiplying a string by a number repeats the string that many times.
Predict Output
advanced
2:00remaining
What error does this code raise if input is 'abc'?
Analyze this code:
Python
value = int(input("Enter a number: "))
print(value + 10)
AValueError
BTypeError
CSyntaxError
D10abc
Attempts:
2 left
💡 Hint
int() cannot convert non-numeric strings to integers.
Predict Output
advanced
2:00remaining
What is the output if the input is '3 4'?
Consider this code:
Python
a, b = input("Enter two numbers separated by space: ").split()
print(int(a) + int(b))
A34
BValueError
C7
DTypeError
Attempts:
2 left
💡 Hint
split() divides the input string into parts separated by spaces.
Predict Output
expert
2:00remaining
What is the output of this code if input is '10'?
Examine this code carefully:
Python
num = input("Enter a number: ")
match num:
    case '10':
        print("Ten")
    case _:
        print("Not Ten")
ATypeError
BNot Ten
CSyntaxError
DTen
Attempts:
2 left
💡 Hint
match-case compares the input string exactly to the case values.