Python Tutorial
1. Introduction to Python
What is Python?
- Python is an interpreted, high-level programming language.
- It is widely used in web development, data science, automation, AI/ML, and more.
- It has simple syntax, making it great for beginners.
Installing Python:
1. Download Python from python.org.
2. Install it and check the version: python --version
3. Use IDLE, VS Code, or PyCharm for writing Python programs.
2. Python Basics
Hello World:
print("Hello, World!")
Variables and Data Types:
name = "Arun" # String
age = 20 # Integer
pi = 3.14 # Float
is_cse_student = True # Boolean
Taking User Input:
name = input("Enter your name: ")
print("Hello, " + name)
, Type Conversion:
num = int(input("Enter a number: "))
print("Double:", num * 2)
3. Control Flow
Conditional Statements:
age = int(input("Enter your age: "))
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Loops:
For Loop:
for i in range(1, 6):
print(i)
While Loop:
num = 1
while num <= 5:
print(num)
num += 1
4. Functions in Python:
def greet(name):
print("Hello, " + name)
1. Introduction to Python
What is Python?
- Python is an interpreted, high-level programming language.
- It is widely used in web development, data science, automation, AI/ML, and more.
- It has simple syntax, making it great for beginners.
Installing Python:
1. Download Python from python.org.
2. Install it and check the version: python --version
3. Use IDLE, VS Code, or PyCharm for writing Python programs.
2. Python Basics
Hello World:
print("Hello, World!")
Variables and Data Types:
name = "Arun" # String
age = 20 # Integer
pi = 3.14 # Float
is_cse_student = True # Boolean
Taking User Input:
name = input("Enter your name: ")
print("Hello, " + name)
, Type Conversion:
num = int(input("Enter a number: "))
print("Double:", num * 2)
3. Control Flow
Conditional Statements:
age = int(input("Enter your age: "))
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Loops:
For Loop:
for i in range(1, 6):
print(i)
While Loop:
num = 1
while num <= 5:
print(num)
num += 1
4. Functions in Python:
def greet(name):
print("Hello, " + name)