0
0
Pythonprogramming~10 mins

Taking input using input() in Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to take input from the user and store it in a variable named name.

Python
name = [1]("Enter your name: ")
Drag options to blanks, or click blank then click option'
Aprint
Bint
Cinput
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Trying to convert input to int without calling input first.
2fill in blank
medium

Complete the code to take an integer input from the user and store it in variable age.

Python
age = [1](input("Enter your age: "))
Drag options to blanks, or click blank then click option'
Astr
Bint
Cfloat
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Not converting input to int and using string directly.
Using float instead of int.
3fill in blank
hard

Fix the error in the code to correctly take two numbers as input and add them.

Python
num1 = int(input("Enter first number: "))
num2 = int([1]("Enter second number: "))
result = num1 + num2
print(result)
Drag options to blanks, or click blank then click option'
Ainput
Bprint
Cint
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to convert print to int.
Missing input() call.
4fill in blank
hard

Fill both blanks to take two inputs from the user and print their sum.

Python
a = int([1]("Enter first number: "))
b = int([2]("Enter second number: "))
print(a + b)
Drag options to blanks, or click blank then click option'
Ainput
Bprint
Cint
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Trying to convert without reading input.
5fill in blank
hard

Fill all three blanks to take a name and age from the user and print a greeting message.

Python
name = [1]("Enter your name: ")
age = [2]([3]("Enter your age: "))
print(f"Hello {name}, you are {age} years old.")
Drag options to blanks, or click blank then click option'
Ainput
Bint
Cprint
Dstr
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of input.
Not converting age to int.