0% found this document useful (0 votes)
4 views2 pages

Python Part 1

This document serves as an introduction to Python, covering its basic syntax, data types, and common programming concepts such as variables, loops, and conditionals. It outlines the steps to get started with Python, including installation and writing a simple program. Additionally, it explains various data structures like lists, tuples, sets, and dictionaries, along with their operations.

Uploaded by

jaishna
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)
4 views2 pages

Python Part 1

This document serves as an introduction to Python, covering its basic syntax, data types, and common programming concepts such as variables, loops, and conditionals. It outlines the steps to get started with Python, including installation and writing a simple program. Additionally, it explains various data structures like lists, tuples, sets, and dictionaries, along with their operations.

Uploaded by

jaishna
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

1. INTRODUCTION TO PYTHON name.

upper()
Used to explain code. [Link]()
Python is a high-level interpreted [Link]()
programming language. Single line: [Link]("P","J")
That means: # This is a comment
Easy to read (almost like English)
Easy to write Multi-line: 11. BOOLEANS
Very powerful """ print(True)
This is print(False)
Used for: multi-line comment Used in conditions:
Web development """ print(5 > 3) # True
Data science
AI & Machine Learning 6. VARIABLES 12. OPERATORS
Automation Arithmetic:
Apps and software Variables store data. + - * / % **
Comparison:
2. GETTING STARTED x = 10 == != > < >= <=
name = "Raja" Logical:
Step 1: Install Python and or not
Download from: Rules:
[Link] No need to declare type 13. COLLECTIONS
Step 2: Check installation Python decides automatically LIST (Ordered, changeable)
Open command prompt: lst = [1,2,3]
python --version 7. DATA TYPES Access:
Step 3: First program Type Example lst[0]
int 10 Change:
print("Hello World") float 10.5 lst[1] = 10
Output: str "Hello" Add:
Hello World bool True [Link](5)
list [1,2,3] [Link](1, 99)
3. PYTHON SYNTAX tuple (1,2,3) Remove:
set {1,2,3} [Link](2)
Python syntax is very simple. dict {"a":1} [Link]()
No need for {} like other Loop:
languages 7. NUMBERS for i in lst:
Indentation (spaces) is very a = 10 # int print(i)
important b = 2.5 # float Copy:
if 5 > 2: c = 3+4j # complex new = [Link]()
print("5 is greater") Nested:
If indentation is wrong → ERROR 9. CASTING (TYPE CONVERSION) lst = [[1,2],[3,4]]
x = int(5.6) # 5 print(lst[0][1])
4. OUTPUT (PRINT) y = float(10) # 10.0
z = str(100) # "100" TUPLE (Ordered, NOT
print("Hello") changeable)
print(10) t = (1,2,3)
print("Age:", 25) 10. STRINGS Access:
name = "Python" t[0]
You can print: Access characters: Convert to change:
Text print(name[0]) # P t = list(t)
Numbers Loop:
Variables for i in name: SET (Unordered, no duplicates)
print(i) s = {1,2,3}
5. COMMENTS Methods: Add:
[Link](5) print("Default")
Remove:
[Link](2) 17. WHILE LOOP
Loop: i=1
for i in s:
print(i) while i <= 5:
print(i)
DICTIONARY (Key-Value pair) i += 1
d = {"name":"Raja", "age":25}
Access: 18. FOR LOOP
d["name"] for i in range(5):
Change: print(i)
d["age"] = 30 Loop through list:
Add: for i in [1,2,3]:
d["city"] = "Chennai" print(i)
Remove:
[Link]("age") FINAL UNDERSTANDING
Loop:  Python is like giving
for k,v in [Link](): instructions step-by-step
print(k,v)  Collections store multiple
Copy: data
new = [Link]()  Conditions help decision
Nested: making
d = {"person":{"name":"Raja"}}  Loops repeat tasks

14. IF...ELSE SIMPLE MEMORY TRICK


x = 10 Think Python like this:
Data → Store (Variables)
if x > 5: Decision → If
print("Big") Repeat → Loop
else: Group → Collec ons
print("Small")

15. IF...ELIF...ELSE
x = 10

if x == 5:
print("Five")
elif x == 10:
print("Ten")
else:
print("Other")

16. MATCH (Switch Case)


x=2

match x:
case 1:
print("One")
case 2:
print("Two")
case _:

You might also like