PART 1 β€’ LEVEL 01

πŸš€ Python Foundations

Understand what Python is, how it runs a program, and the small set of syntax rules you need before solving your first problems.

⏱ 60–75 minutes πŸ“š 7 concepts πŸ’» 6 programs 🧠 5-question quiz
first_program.py Python 3
# My first Python program
name = "Venu"
goal = "learn Python"

print(f"Hello, {name}!")
print(f"Today I will {goal}.")
OUTPUTHello, Venu!
Today I will learn Python.

By the End of This Level

You will be able to explain and write the foundations of a Python program.

01

Describe Python and where it is used.

02

Explain source code, interpreter and output.

03

Run Python using IDLE, VS Code or an online editor.

04

Use print(), indentation and comments correctly.

01

What Is Python?

Python is a high-level, general-purpose programming language designed to make programs easy to read and write. Instead of managing many low-level details, you can focus on the problem and its solution.

Simple definition

Python is a language used to give clear instructions to a computer.

πŸ“–

Readable

Its syntax looks close to normal English and uses fewer symbols.

▢️

Interpreted

An interpreter executes the program without a separate manual compilation step.

🌍

Portable

The same program can run on Windows, Linux and macOS with little or no change.

🧰

Rich Ecosystem

Thousands of libraries support web, automation, data science, AI and more.

Web DevelopmentDjango, Flask, FastAPI
AI & Machine LearningPyTorch, TensorFlow, scikit-learn
Data AnalysisNumPy, pandas, Matplotlib
AutomationFiles, reports, emails and repetitive tasks
02

How Python Runs a Program

You write instructions in a .py file. The Python interpreter reads them and performs the requested operations.

1Source Codehello.py
2InterpreterReads and executes
3OutputResult or error
Remember

Python normally executes statements from top to bottom. If it finds an error, it stops and shows a message that helps locate the problem.

03

Three Easy Ways to Run Python

BEST FOR PROJECTS

πŸ§‘β€πŸ’» VS Code

A flexible editor with the official Python extension, terminal and debugging tools.

  1. Install Python 3 and VS Code.
  2. Install the Python extension.
  3. Create a .py file.
  4. Click Run Python File.
NO INSTALLATION

🌐 Online Editor

Useful for quick practice when you cannot install software on the computer.

  1. Open a trusted Python editor.
  2. Choose Python 3.
  3. Type your program.
  4. Click Run and inspect the output.
Version check

Open Command Prompt and run python --version. If Windows uses the launcher, try py --version. Continue with a Python 3 version.

04

Display Output with print()

print() is a built-in Python function. It displays text, numbers or calculated values on the screen.

EXAMPLE 1

Hello, CodeBhavya!

print("Hello, CodeBhavya!")
print("I am learning Python.")
OUTPUT
Hello, CodeBhavya!
I am learning Python.
print("Hello, Python!")
Function nameOperation to perform ParenthesesHold the function input StringText inside quotes
EXAMPLE 2

Print Text, Numbers and a Calculation

print("My age is", 35)
print("10 + 5 =", 10 + 5)
print("Python", "is", "easy")
OUTPUT
My age is 35
10 + 5 = 15
Python is easy

What Happens During Execution?

StepStatementPython's actionOutput so far
1print("My age is", 35)Displays the two values with a space.My age is 35
2print("10 + 5 =", 10 + 5)Calculates 15, then displays it.10 + 5 = 15
3print("Python", "is", "easy")Displays three strings separated by spaces.Python is easy
05

Python Syntax and Case Sensitivity

1

One Statement per Line

print("First")
print("Second")
2

Quotes Must Match

print("Correct")
print('Also correct')
3

Python Is Case-Sensitive

name = "Bhavya"
Name = "Python"

name and Name are different.

4

Parentheses Must Balance

print("Balanced")
βœ“ CORRECT
print("Welcome")

Matching quotes and closing parenthesis.

βœ• ERROR
Print("Welcome")

Print is not the same as print.

06

Indentation in Python

Indentation means spaces at the beginning of a line. Python uses indentation to group statements that belong together. Most Python style uses four spaces for one indentation level.

βœ“ CORRECT
is_ready = True

if is_ready:
    print("Start learning")

print("Program finished")

The indented statement belongs to the if block.

βœ• INDENTATION ERROR
is_ready = True

if is_ready:
print("Start learning")

Python expects an indented block after the colon.

Good habit

Do not mix tabs and spaces. Configure your editor to insert four spaces when you press Tab.

07

Comments

A comment is a note for people reading the code. Python ignores a single-line comment beginning with #.

EXAMPLE 3

Useful Comments

# Display the course name
print("CodeBhavya Python")

# Calculate the total number of classes
weeks = 4
classes_per_week = 3
print(weeks * classes_per_week)
OUTPUT
CodeBhavya Python
12
βœ“

Explain why a non-obvious step is needed.

βœ“

Keep the comment short and update it when code changes.

βœ•

Avoid comments that merely repeat an obvious statement.

Common Beginner Mistakes

SyntaxError
print("Hello)

The opening and closing quotes do not match.

NameError
Print("Hello")

Python does not know a function named Print.

IndentationError
if True:
print("Yes")

The statement after the colon must be indented.

Read an error in this order:1. Error type2. File and line number3. Message4. The marked code
QUICK REVISION

πŸ“Œ Python Foundations β€” Quick Revision

Review the complete Level 1 lesson in two minutes before attempting the quiz and programming problems.

01

Python is a readable, high-level and general-purpose programming language.

02

A Python source file normally uses the .py extension.

03

The Python interpreter reads and executes program instructions.

04

Statements normally execute from top to bottom.

05

print() displays text, numbers and calculated results.

06

Text values must be written inside matching single or double quotes.

07

Python is case-sensitive: print and Print are different.

08

Indentation groups statements; four spaces are the standard style.

09

A single-line comment begins with the # symbol.

10

Read an error using its type, line number, message and marked code.

Level 1 Quick Quiz

Select one answer for every question, then check your score.

5 Questions
1Which component reads and executes a Python program?
2Which statement correctly displays Hello?
3Which symbol starts a single-line Python comment?
4What is the standard indentation used for one Python block?
5What is the output of print("2 + 3 =", 2 + 3)?

08

Level 1 Practice

Type and run each program before opening the solution.

BEGINNER β€’ 01

Personal Introduction

Print your name, department and goal on three separate lines.

Sample outputMy name is Venu
Department: CSE-AI&ML
Goal: Learn Python

BEGINNER β€’ 02

Decorative Course Card

Use multiple print() calls to display a simple course title inside a border made with equal signs.

Sample output====================
CODEBHAVYA PYTHON
====================

BEGINNER β€’ 03

Predict the Output

Write the output without running the program first.

print("Result:", 8 + 2)
print("Python" * 2)
DEBUGGING β€’ 04

Correct the Errors

Find and correct every error in this program.

Print("Welcome to Python")
print("Let us learn Python)
if True:
print("Ready")
PRACTICE

🎯 5 Programming Problems β€” Python Foundations

Try every problem yourself first. Open πŸ’» Solve It Yourself to write and test your program, use Hint only when required, and open Show Program to study the official solution.

πŸ“ˆ Python Foundations Practice Progress
Solved0 / 5
Completed with Solution0
Total Score0 / 500
Completion0%

A problem counts as Solved when its output passes before the official solution is opened.

1. Welcome Message

Write a Python program that displays the exact welcome message.

Input: No inputOutput: Hello, Python!
2. Student Learning Card

Display the student's name, course and learning goal on separate lines.

Input: No inputOutput: Three labelled lines
3. Display a Calculation

Display the label 10 + 5 = followed by the calculated result.

Input: No inputOutput: 10 + 5 = 15
4. CodeBhavya Course Banner

Create a three-line banner using equal signs and the course name.

Input: No inputOutput: A formatted three-line banner
5. Debug the Program

Correct the function name and indentation so both messages are displayed.

Input: No inputOutput: Ready and Program finished
KEY TAKEAWAY

🎯 Think Clearly Before You Code

1Understand

What result should the program produce?

β†’
2Write

Express the solution using clear Python statements.

β†’
3Run

Let the interpreter execute the statements.

β†’
4Verify

Compare the actual output with the expected output.

Strong Python programming begins with readable code, correct indentation and careful output verificationβ€”not with memorizing programs.

INTERACTIVE LEARNING

🎬 Python Program β€” Visual Flow

Follow a Python program from the moment you write the source code until you inspect its result.

PROGRAM TRACING

πŸ”Ž Program Tracing β€” Python Foundations

Move through the program one statement at a time and observe how values and output change.

INTERVIEW PREPARATION

🎀 Python Foundations β€” Interview Questions

Try to answer aloud before opening each explanation.

1.

What makes Python a high-level programming language?

2.

What is the role of the Python interpreter?

3.

Why is indentation important in Python?

4.

Is Python case-sensitive? Give one example.

5.

What can the print() function display?

6.

How do comments help a Python program?

EXTRA TIPS

πŸ’‘ Python Foundations β€” Extra Tips

  • 01

    Type every example yourself; typing develops syntax memory faster than reading alone.

  • 02

    Use meaningful filenames such as first_program.py instead of vague names.

  • 03

    Run the program after small changes so errors are easier to locate.

  • 04

    Read error messages from the last line first to identify the error type and message.

  • 05

    Use four spaces consistently and configure the editor to convert Tab into spaces.

  • 06

    Predict the output before running a program; this builds strong tracing ability.

EXTRA PRACTICE

✍️ Python Foundations β€” Extra Practice Questions

  1. Write a program that displays your name and city on separate lines.
  2. Print the words Learn, Practice and Build using one print() call.
  3. Display the result of 25 + 15 with a suitable label.
  4. Create a five-line profile card using only print() statements.
  5. Write two valid comments explaining the purpose of a small program.
  6. Predict the output of print("Code" * 3) before running it.
  7. Correct this statement: Print('Python').
  8. Correct the missing quote in print("Welcome).
  9. Write a correctly indented if True: block that prints Learning.
  10. Create and run a .py file, then explain the source-code-to-output flow in your own words.

Python Foundations Complete

When you can explain the execution flow and write the practice programs without help, mark this level complete and continue.