Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
print instead of input.Trying to convert input to int without calling input first.
✗ Incorrect
The
input() function reads a line from input and returns it as a string.2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Not converting input to int and using string directly.
Using
float instead of int.✗ Incorrect
Use
int() to convert the input string to an integer.3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to convert
print to int.Missing
input() call.✗ Incorrect
The second number must be read using
input() before converting to int.4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
print instead of input.Trying to convert without reading input.
✗ Incorrect
Both inputs must be read using
input() before converting to int.5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
print instead of input.Not converting age to int.
✗ Incorrect
Use
input() to read name and age, then convert age to int.