Lesson 4: Taking User Input βοΈ
Now, letβs make our program interactive by using the input() function!
Example:
# Taking user input
name = input("What is your name? ")
age = input("How old are you? ")
print("Hello", name + "! You are", age, "years old.")
Explanation:
input() prompts the user for input.
The result is always a string.
Task:
Write a program that asks for your name and favorite hobby, then prints a message like:
"Hi [Name], your favorite hobby is [Hobby]!"
Share your code and output in the group!
Next, weβll learn about if-else conditions to make decisions in your programs.
β€οΈ If youβre vibing with posts like this, drop a heart β Iβll keep them coming Stay tuned! π
π Must join our Channel @TIGRAYTECHC
Now, letβs make our program interactive by using the input() function!
Example:
# Taking user input
name = input("What is your name? ")
age = input("How old are you? ")
print("Hello", name + "! You are", age, "years old.")
Explanation:
input() prompts the user for input.
The result is always a string.
Task:
Write a program that asks for your name and favorite hobby, then prints a message like:
"Hi [Name], your favorite hobby is [Hobby]!"
Share your code and output in the group!
Next, weβll learn about if-else conditions to make decisions in your programs.
β€οΈ If youβre vibing with posts like this, drop a heart β Iβll keep them coming Stay tuned! π
π Must join our Channel @TIGRAYTECHC