Hi Elon Musk, What's your Age? | 001 Learn Python in Bits

Ever wondered how to ask Elon Musk his age in Python! Let me tell you how?

Hi 👋

Welcome again to the first edition of Learn Python in Bits.

In case, you haven’t checked our FREE Python course, check it here.

If this mail is forwarded, and you haven’t subscribed to it yet? Subscribe Now.

Elon Musk in Python!

Print function and Input Function

Let’s briefly introduce Python and Understand what the above code means.

print()

This is called Print Function!
- as the name suggests it prints something.

inside the parenthesis (), we have 2 quotes ““, we have something written in between, what is that? 👀

That’s a message you want to show a user!

like, For the below example, we have “hello“ as a message written

Here’s a quick example ;)

print("hello")

Output : hello

Now, let’s see another one

input()

I know you’re Smart enough to guess! 😎

It takes input from the User.

But what does ‘name’ here mean?

name is like a container (or a box) that stores a value.

Officially, we call it Variable.

Variable

A variable can have any name (there are some rules but for later, hmm)

Oh Rules! we’ll talk about that later.

As for now, understand a variable can have any name like ‘age’ in the first snapshot. It could be ‘answer‘ or ‘ans’ or ‘a

👨‍💻 Very simple right?

Here’s an example 👇

name = input("Enter name :")

Output : Enter name :

but, it also asks the user to input something!

Whatever a user inputs, it is stored inside the “name” variable.

Let’s say User A inputted 1

now name variable stores 1 (integer value)

and, any User B inputted for the same, ‘Elon Musk’

now, the name variable stores ‘Elon Musk’ (string value)

Here’s a quick illustration :

Visual representation of Variable in Python

🎁 Bonus

You can use print() to print the value stored in a variable.

a = 'Elon Musk'

print(a)

You’re so clever🤌 You already guessed the Output.

Yes! Output : ‘Elon Musk‘

Recap 😃 

Today’s Learn Python in Bits issue, you learned -

  1. Print Function

  2. Input Function

  3. Variables

That’s not it! There are much more to learn in detail

Learn Python in our FREE course! (It’s still in building, so right now videos will not be available)

Click here to get started!

A Quiz?

Everybody likes a quiz, and we have a reward for active people 😎

Cool right?

print("Hello Elon Musk 👋")

ans = input("Will you make me CEO of X? y or n")

print(ans)

What should Elon Musk reply? Let us know in reply 😥

Subscribe to keep reading

This content is free, but you must be subscribed to Learn Python in Bits to continue reading.

Already a subscriber?Sign In.Not now