Lesson 2: Inputs and Variables

Lesson 2: Inputs and Variables

All the talk about AI (Artificial Intelligence) is exciting, isn’t it? AlphaGo defeated World Champion at a complex game like Go, while a computer was able to bluff an expert poker player. Today, we will try to understand how AI, or any code for that matter, emulates a human being in understanding the world. We have two eyes, a nose, a mouth, our skin and our ears to absorb information from the world around us, and assimilate the information to assess our next steps. Similarly, any code tries to understand the world around through ‘INPUTS’, or specific data fed to it by the user. Today, our aim would be to take data from the user, and store it in modular containers called ‘VARIABLES’. Think of a hot cappuccino as the input, and your mouth as the variable. Once the coffee is in your mouth, what you do with it – gulp or spit – is upto your brain. Similarly, once we store data in the variable we can use it in various ways.

Through this lesson, we will also understand the basic need for names, as a medium to represent large amounts of data in a few characters. We will also understand the sense in reusing the same data for multiple purposes.


  • To take data from the user and store it in a variable
Skills Imparted:

  • Basis input/output skills
  • Introduction to variables

  • Install python and python developer
  • Lesson-1: Hello World (Output in Python)

5 mins

Do now:

  1. What is the name of your best friend? If he/she didn’t have this name, how would you refer to him/her?
  2. Revision: Write code to print “Hi, my name is _______” on the screen.
I do:

Our first activity today would be to find the names of your parents and display them on the screen. We will take their ages and store their names in a container called a ‘VARIABLE”. This way of taking data from user is called ‘INPUT’.


  • Take father’s name into a variable
  • Take mother’s name into a variable
  • Print father’s name and mother’s name
father=input(“Please enter your father’s name:”)
mother=input(“Please enter your mother’s name:”)
print(“Father’s name is:”, father)
print(“Mother’s name is:”, mother)

  1. Write the code in the Python editor
  2. Save this file as ‘parents.py’
  3. Press F8 button to compile
  4. Check for errors
  5. If no errors, press F5 to run
We do:

  • Now, let’s write code to take the name of your favourite movie, a dialogue from it and print them on the screen.


  1. Write the code in the Python editor
  2. Save this file as ‘parents.py’
  3. Press F8 button to compile
  4. Check for errors

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: