0% found this document useful (0 votes)
20 views4 pages

Python Notes

Uploaded by

Shivam Kholia
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)
20 views4 pages

Python Notes

Uploaded by

Shivam Kholia
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/ 4

Python Notes with Syntax

# Python Notes with Syntax

## 1. Introduction to Python

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

supports multiple programming paradigms, including procedural, object-oriented, and functional

programming.

## 2. Python Basics

### Variables and Data Types

x = 10 # Integer

y = 3.14 # Float

name = "Alice" # String

is_active = True # Boolean

### Input and Output

name = input("Enter your name: ")

print("Hello,", name)

## 3. Control Flow

### Conditional Statements

if condition:

# Code block

Page 1
Python Notes with Syntax

elif another_condition:

# Code block

else:

# Code block

### Loops

for i in range(5):

print(i)

## 4. Functions

def function_name(parameters):

# Code block

return value

def add_numbers(a, b):

return a + b

result = add_numbers(5, 3)

## 5. Data Structures

### Lists

my_list = [1, 2, 3, 4]

### Dictionaries

Page 2
Python Notes with Syntax

my_dict = {"name": "Alice", "age": 25}

## 6. Object-Oriented Programming

class Person:

def __init__(self, name, age):

self.name = name

self.age = age

def greet(self):

print(f"Hello, my name is {self.name}.")

person = Person("Alice", 25)

## 7. File Handling

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

content = file.read()

with open("file.txt", "w") as file:

file.write("Hello, World!")

## 8. Exception Handling

try:

result = 10 / 0

except ZeroDivisionError:

print("Cannot divide by zero!")

Page 3
Python Notes with Syntax

## 9. Libraries and Modules

import math

print(math.sqrt(16))

Page 4

You might also like