Welcome to Darchums Tech!
Today, you'll learn the basics of Python—starting with variables and user input.
In Python, a variable is like a labeled box that stores information. You can name it anything and assign it a value.
Let’s try it!
We’ll create a variable called name and assign it the text value 'Alice'.
Then, we’ll ask the user to enter their name using the input function.
Here’s the magic line:
name = input("What is your name? ")
This asks the user a question, and stores their answer in the variable 'name'.
Finally, we can greet them:
print("Hello, " + name + "!")
Just like that, your program becomes interactive!
Now go ahead—try this code in your Python editor and have some fun!
Don’t forget to like, share, and subscribe for more Python tips with Darchums.
Comments
Post a Comment