DEV Community

Wriju's Blog
Wriju's Blog

Posted on

Day 2 - Variables for Text [Python for Students]

You have observed how you can print a simple text into the python window. However, there is a small challenge, if you have to type the same text again and again, you need to either copy and paste it into your print function every time or type. If we can use a small indicator to store the whole text then every time we can just simply use that indicator to print it. It's like a roll number given to a student. When a teacher discusses about student they can mention the roll number instead of calling out the full name or all the features of that individual. That's why we use names for everything. Same happens in programming language, we use a name to store the whole string and that name is often known as variable.

We will see how differently we can use our greetings and print them by their name.

gm = "Good morning"
print(gm)
Enter fullscreen mode Exit fullscreen mode

In Above gm is the variable name which can be used later as well. Every time you don't need to type the whole text. Just use the name wherever needed.

Watch the video

Day 2 - Exercise

  1. Create a variable with a name myname and assign the value of your name. Then call the variable in print() function.
  2. Create a variable for your favourite movie and print() it.
  3. Clear all the output.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly β€” using the tools and languages you already love!

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay