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

Python Notes

This document provides an overview of Python, covering its basic features such as data types, input/output, operators, conditional statements, loops, functions, lists, dictionaries, and exception handling. It emphasizes Python's simplicity and readability, along with practical examples for each topic. The notes serve as a foundational guide for beginners learning Python programming.

Uploaded by

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

Python Notes

This document provides an overview of Python, covering its basic features such as data types, input/output, operators, conditional statements, loops, functions, lists, dictionaries, and exception handling. It emphasizes Python's simplicity and readability, along with practical examples for each topic. The notes serve as a foundational guide for beginners learning Python programming.

Uploaded by

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

Python Notes

1. Introduction to Python
Python is a high-level, interpreted, and object-oriented programming language. It is known
for its simplicity and readability. Python uses indentation instead of curly brackets {}.

2. Variables and Data Types


Example of variables:

x = 10 # Integer
y = 3.14 # Float
name = "John" # String
is_active = True # Boolean

3. Input and Output


Printing Output:

print("Hello, World!")

Taking User Input:

name = input("Enter your name: ")


print("Hello,", name)

4. Operators in Python
Arithmetic Operators:

a = 10
b=3
print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division

5. Conditional Statements

x = 20
if x > 10:
print("x is greater than 10")
elif x == 10:
print("x is 10")
else:
print("x is less than 10")

6. Loops in Python
For Loop:

for i in range(5):
print(i) # 0 1 2 3 4

While Loop:

x=1
while x <= 5:
print(x)
x += 1

7. Functions in Python

def greet(name):
print("Hello,", name)

greet("Alice") # Output: Hello, Alice

8. Lists in Python

fruits = ["apple", "banana", "cherry"]


print(fruits[0]) # Output: apple

9. Dictionaries in Python

student = {
"name": "John",
"age": 20,
"grade": "A"
}

print(student["name"]) # Output: John

10. Exception Handling

try:
num = int(input("Enter a number: "))
result = 10 / num
except ZeroDivisionError:
print("Cannot divide by zero!")
except ValueError:
print("Invalid input! Enter a number.")

You might also like