Python Lesson 1

Starting Python with print(), input() and Simple Calculations

Today we begin from absolute zero. By the end of this lesson, you will make Python talk, take information from the user, and calculate useful answers like a tiny smart assistant.

1. What is Python?

Python is a programming language. A programming language is a way to give instructions to a computer. You write clear commands, and the computer follows them.

Think of Python as a very obedient student. It does not guess much. It does exactly what you write. If you write correct instructions, Python gives correct results. If you write unclear instructions, Python complains with an error.

Imagine this: You are opening a small tea shop. You want Python to greet customers, ask their name, take the number of tea cups, calculate the bill, and print the final amount. That is what this lesson will teach.

Today’s Skills

  • Display messages using print()
  • Take user input using input()
  • Store values in variables
  • Convert text into numbers
  • Do addition, subtraction, multiplication and division
  • Build tiny useful programs

2. Making Python Speak with print()

The first command most learners use in Python is print(). It displays something on the screen.

print("Hello, Python!")
Hello, Python!

How it works

Part Meaning
print The command that displays output
() Parentheses hold the thing we want to print
"Hello, Python!" Text written inside quotes

Print more than one thing

print("My name is Champak.")
print("I am learning Python.")
print("Python is useful.")
My name is Champak.
I am learning Python.
Python is useful.

Printing numbers

Text needs quotes. Numbers do not need quotes.

print(10)
print(25)
print(100)

Printing text and numbers together

print("Age:", 25)
print("Tea cups:", 4)
print("Price:", 40)
Age: 25
Tea cups: 4
Price: 40
Important: In Python, commas inside print() help you print many things together.
Practice Task 1

Print your name, your city, and one thing you want to learn in Python.

print("My name is _____")
print("I live in _____")
print("I want to learn _____")

3. Variables: Small Boxes for Data

A variable is like a named box. You can store something inside it and use it later.

name = "Amit"
age = 15

print(name)
print(age)
Amit
15

Better output

name = "Amit"
age = 15

print("Name:", name)
print("Age:", age)
Name: Amit
Age: 15
Remember: The variable name is written without quotes. The text value is written inside quotes.

Good variable names

Good Not Good Reason
student_name s Clear names are easier to understand
total_marks tm Full meaning is visible
tea_price tp Readable code is better code

4. Taking User Input with input()

input() lets Python ask a question and wait for the user to type an answer.

name = input("What is your name? ")
print("Welcome,", name)
What is your name? Ravi
Welcome, Ravi

Make it feel like a conversation

name = input("Enter your name: ")
city = input("Enter your city: ")

print("Hello", name)
print("You are from", city)
print("Welcome to Python class!")
This is your first chatbot-like program. It asks, receives, stores, and replies.

Very important: input() gives text

Whatever comes from input() is treated as text first, even if the user types a number.

age = input("Enter your age: ")
print(age)

Here age looks like a number, but Python stores it as text. This matters when we want to calculate.

5. Simple Calculations in Python

Python can work like a calculator.

Addition
print(10 + 5)
Subtraction
print(10 - 5)
Multiplication
print(10 * 5)
Division
print(10 / 5)
Power
print(2 ** 3)
Remainder
print(10 % 3)

Calculation with variables

price = 10
quantity = 5

total = price * quantity

print("Total bill:", total)
Total bill: 50

The common beginner mistake

Look at this program:

a = input("Enter first number: ")
b = input("Enter second number: ")

print(a + b)

If the user enters 10 and 20, the output will be:

1020

Why? Because input() gives text. Python joins the text instead of adding numbers.

The solution: convert text into numbers

Use int() for whole numbers.

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

sum_result = a + b

print("Sum:", sum_result)
Enter first number: 10
Enter second number: 20
Sum: 30

Use float() for decimal numbers

float() is used for numbers with decimal points.

length = float(input("Enter length: "))
width = float(input("Enter width: "))

area = length * width

print("Area:", area)
Enter length: 5.5
Enter width: 2
Area: 11.0

6. Mini Projects

Now let us make tiny useful programs. These are small, but they teach the real habit of programming: input, process, output.

Champak Roy
Teacher Note: Do not just read these programs. Type them. Break them. Change numbers. Change names. Make mistakes. Fix them. That is how Python enters the mind.

Project 1: Tea Shop Bill Calculator

customer_name = input("Enter customer name: ")
cups = int(input("How many cups of tea? "))

price_per_cup = 10
total = cups * price_per_cup

print("Customer:", customer_name)
print("Cups:", cups)
print("Total bill: Rs.", total)

Project 2: Simple Marks Calculator

name = input("Enter student name: ")

maths = int(input("Enter Maths marks: "))
science = int(input("Enter Science marks: "))
english = int(input("Enter English marks: "))

total = maths + science + english
average = total / 3

print("Student:", name)
print("Total marks:", total)
print("Average marks:", average)

Project 3: Age Calculator

name = input("Enter your name: ")
birth_year = int(input("Enter your birth year: "))
current_year = int(input("Enter current year: "))

age = current_year - birth_year

print("Hello", name)
print("Your age is approximately", age)

Project 4: Rectangle Area Calculator

length = float(input("Enter rectangle length: "))
width = float(input("Enter rectangle width: "))

area = length * width

print("Area of rectangle:", area)

Project 5: Your First Friendly Assistant

name = input("What is your name? ")
city = input("Which city are you from? ")
goal = input("What do you want to learn? ")

print("Hello", name)
print("Nice to meet someone from", city)
print("Your learning goal is:", goal)
print("Keep practicing. Python will become easy!")

7. Input, Process, Output

Most beginner programs follow this simple pattern:

Input

Take information from the user.

cups = int(input("Cups: "))

Process

Calculate or prepare the result.

total = cups * 10

Output

Show the answer.

print("Bill:", total)
Once you understand input, process and output, you can create bill calculators, marks calculators, interest calculators, converters, small games, and later even data science programs.

8. Common Errors and Fixes

Error Wrong Code Correct Code
Missing quotes around text print(Hello) print("Hello")
Using input number without conversion age = input("Age: ") age = int(input("Age: "))
Wrong multiplication symbol total = price x qty total = price * qty
Wrong variable spelling print(nmae) print(name)

9. Practice Questions

Question 1

Ask the user for their name and print a welcome message.

Question 2

Ask the user for two numbers and print their sum.

Question 3

Ask the user for the price of one notebook and the number of notebooks. Print the total cost.

Question 4

Ask for marks in 5 subjects. Print total marks and average marks.

Question 5

Ask for distance and time. Print speed using this formula: speed = distance / time.

10. Practice in the Python Editor

Type the examples below in the editor. Start small. First run print(). Then run input(). Then create a calculator.


11. Quick Quiz

1. Which command displays output in Python?
Show Answer

print()

2. Which command takes input from the user?
Show Answer

input()

3. What is the output of this?
print(5 + 3)
Show Answer

8

4. Why do we use int(input())?
Show Answer

Because input() gives text. int() converts that text into a whole number.

5. What is the output?
a = "10"
b = "20"
print(a + b)
Show Answer

1020, because both values are text.

12. Final Challenge

Make a complete small program called My First Python Bill Maker.

Your program should:

customer = input("Enter customer name: ")
item = input("Enter item name: ")
price = float(input("Enter item price: "))
quantity = int(input("Enter quantity: "))

total = price * quantity

print("---------------------")
print("BILL")
print("---------------------")
print("Customer:", customer)
print("Item:", item)
print("Price:", price)
print("Quantity:", quantity)
print("Total: Rs.", total)
print("---------------------")
print("Thank you!")
Congratulations. If you understand this final challenge, you have started real programming. You can now build small useful Python programs.