0% found this document useful (0 votes)
15 views16 pages

Python Basics: Print, Variables, Loops

Uploaded by

dineshcto24
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)
15 views16 pages

Python Basics: Print, Variables, Loops

Uploaded by

dineshcto24
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

Python Beginner Steps with Examples

1. Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.
def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.
for i in range(5):
print(i)

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)
3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)
Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"
print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.
for i in range(5):
print(i)

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)
3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)
Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"
print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.
for i in range(5):
print(i)

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)
3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.

def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)
Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.
def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)
Printing Output
Use the print() function to display output.

print("Hello, World!")

2. Variables and Data Types


Variables store data. Python supports various data types like int, float, str, and bool.

x = 10
name = "Alice"
is_active = True
print(x, name, is_active)

3. Conditional Statements
Use if, elif, and else to make decisions in code.

age = 18
if age >= 18:
print("Adult")
else:
print("Minor")

4. Loops
Use for and while loops to repeat actions.

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

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

5. Functions
Functions are reusable blocks of code defined using def.
def greet(name):
return f"Hello, {name}!"

print(greet("Bob"))

6. Lists
Lists store multiple items in a single variable.

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


for fruit in fruits:
print(fruit)

You might also like