Skip to main content
Basic 2 hours Programming Languages

Introduction to Python

Learn Python basics β€” variables, data types, operators, and your first program. Hour-based structured tutorial with MCQs and practice programs.

Learning Outcomes

  • Understand Python syntax and indentation
  • Declare variables and use basic data types
  • Write and run your first Python program
  • Use input/output and basic operators

Learning Outcomes

By the end of this tutorial, you will be able to write simple Python programs, understand variables and data types, and solve basic programming problems.

Basic Level

Python is a high-level, interpreted programming language known for its readability and versatility.

# Your first Python program
print("Hello, LEARNCODEGURU!")

name = input("Enter your name: ")
print(f"Welcome, {name}!")

Variables & Data Types

Type Example Description
int 42 Whole numbers
float 3.14 Decimal numbers
str "Hello" Text strings
bool True Boolean values

Advanced Level

Type hints and f-strings for production-quality code:

def greet(name: str, age: int) -> str:
    return f"Hello {name}, you are {age} years old."

print(greet("Raghu", 22))

Interview Level

Q: Is Python interpreted or compiled? Python is primarily interpreted, but CPython compiles source to bytecode (.pyc) before execution.

Q: Difference between list and tuple? Lists are mutable; tuples are immutable and typically used for fixed collections.

Application Level

Build a simple grade calculator that takes marks and outputs the grade letter.

MCQs

Basic MCQ

  1. Which keyword is used to define a function in Python?
    • A) func B) def C) function D) define
    • Answer: B

Output-Based MCQ

x = 5
y = 2
print(x // y, x % y)
  • Output: 2 1

Practice Programs

  1. Write a program to swap two numbers without a third variable.
  2. Write a program to check if a number is even or odd.
  3. Calculate the area of a circle given its radius.

Project Ideas

  • CLI Calculator β€” Basic arithmetic operations
  • Student Record Manager β€” Store and display student data
  • Number Guessing Game β€” Random number with hints