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

Complete Python Notes

Uploaded by

salviayush86
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)
0 views3 pages

Complete Python Notes

Uploaded by

salviayush86
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

Complete Python Notes

1. Introduction to Python

Python is a high-level, interpreted programming language known for its simplicity.

Example:
print('Hello, World!')

2. Variables and Data Types

Variables are used to store data.


Data types include: int, float, str, bool, list, tuple, set, dict.

Example:
x = 10
name = 'Alice'
is_happy = True

3. Operators

Operators perform operations on variables.


Types: Arithmetic (+, -, *, /), Comparison (==, !=), Logical (and, or, not).

Example:
result = 5 + 3
print(result > 6 and result < 10)

4. Conditional Statements

if, elif, and else are used to perform decisions.

Example:
age = 18
if age >= 18:
print('Adult')
else:
print('Minor')
Complete Python Notes

5. Loops

Used to repeat a block of code.


for loop and while loop are common.

Example:
for i in range(5):
print(i)

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

6. Functions

Functions are blocks of reusable code.

Example:
def greet(name):
print('Hello,', name)
greet('Alice')

7. Lists and Tuples

List: Mutable, Tuple: Immutable.

Example:
my_list = [1, 2, 3]
my_tuple = (1, 2, 3)
print(my_list[0])

8. Dictionaries

Dictionaries store data in key-value pairs.

Example:
Complete Python Notes

person = {'name': 'Bob', 'age': 25}


print(person['name'])

9. File Handling

Used to read/write files.

Example:
with open('file.txt', 'w') as f:
f.write('Hello file')

10. Object-Oriented Programming

Python supports OOP with classes and objects.

Example:
class Person:
def __init__(self, name):
self.name = name

def greet(self):
print('Hello', self.name)

p = Person('Alice')
p.greet()

You might also like