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