0% found this document useful (0 votes)
3 views2 pages

Lesson 1 Python Basics

This document provides an introduction to Python programming, covering its basic concepts such as variables, data types, input/output, operators, conditional statements, loops, and functions. It includes examples of arithmetic, comparison, and logical operators, as well as how to implement loops and define functions. Overall, it serves as a foundational lesson for beginners in Python.

Uploaded by

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

Lesson 1 Python Basics

This document provides an introduction to Python programming, covering its basic concepts such as variables, data types, input/output, operators, conditional statements, loops, and functions. It includes examples of arithmetic, comparison, and logical operators, as well as how to implement loops and define functions. Overall, it serves as a foundational lesson for beginners in Python.

Uploaded by

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

Lesson 1: Python Basics

1. Introduction to Python
Python is an interpreted, high-level, dynamically typed programming language.

2. Variables and Data Types


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

3. Input and Output


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
print(a // b) # Floor Division
print(a % b) # Modulus
print(a ** b) # Exponentiation

# Comparison Operators
print(a == b) # Equal to
print(a != b) # Not equal to
print(a > b) # Greater than
print(a < b) # Less than

# Logical Operators
print(a > 5 and b < 5) # AND
print(a > 5 or b > 5) # OR
print(not(a > 5)) # NOT

5. Conditional Statements
num = int(input("Enter a number: "))

if num > 0:
print("Positive number")
elif num < 0:
print("Negative number")
else:
print("Zero")

6. Loops in Python
# For Loop
for i in range(5):
print(i) # Prints 0 to 4

# While Loop
count = 0
while count < 5:
print(count)
count += 1 # Increment
7. Functions in Python
def greet(name):
return "Hello, " + name

print(greet("Alice"))

You might also like