Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views3 pages

Python Basics Teacher Guide

Uploaded by

webernih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Python Basics Teacher Guide

Uploaded by

webernih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Basics – Teacher Style Guide

1. Introduction to Python
Python is a high-level, interpreted programming language. It is easy to read and write, making it perfect
for beginners.
Python uses indentation (spaces) instead of curly braces {} to define code blocks.

Example:
print("Hello, World!")

2. Variables
Variables store data values. Python automatically detects the type.

Example:
name = "LIXRL" # string
age = 18 # integer
height = 5.9 # float
is_student = True # boolean

3. Data Types
Python has several basic types:
- int: 10
- float: 3.14
- str: "Hello"
- bool: True or False
- list: [1,2,3]
- tuple: (1,2,3)
- dict: {"name": "LIXRL", "age": 18}
- set: {1,2,3}

4. Operators
- Arithmetic: + - * / % // **
- Comparison: == != > < >= <=
- Logical: and, or, not

Example:
a = 5; b = 3
print(a + b) # 8
print(a > b) # True

5. Conditional Statements (if-else)


age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

6. Loops
For loop repeats for a fixed number of times:
for i in range(5):
print(i)

While loop runs until condition is false:


count = 0
while count < 5:
print(count)
count += 1

7. Functions
Functions group code together.
def greet(name):
print(f"Hello, {name}!")

greet("LIXRL")

Functions can return values:


def add(a, b):
return a + b

print(add(5,3))

8. Lists
Lists store multiple ordered items.
fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
print(fruits[0])

9. Dictionaries
Store key-value pairs.
person = {"name":"LIXRL","age":18}
print(person["name"])
person["age"] = 19

10. File Handling


with open("test.txt", "w") as file:
file.write("Hello LIXRL!")

with open("test.txt", "r") as file:


print(file.read())

11. Comments
Use # for single-line, and triple quotes for multi-line comments.

# This is a comment
"""
This is a multi-line comment
"""

Summary:
- Python is beginner-friendly
- Use variables, data types, loops, conditions
- Functions make code reusable
- Lists and dictionaries store multiple values
- Files allow saving and reading data
- Comments explain code

You might also like