Python_Basics_Flashcards
Python_Basics_Flashcards
Introduction to Python
Python is a high-level, interpreted programming language known for its simplicity and readability. It is widely
used in web development, data analysis, artificial intelligence, scientific computing, and more.
Operators in Python
Control Flow
if x > 0:
print('Positive')
elif x == 0:
print('Zero')
else:
print('Negative')
Python Basics - Beginner to Advanced
- Loops:
for i in range(5):
print(i)
while x < 5:
x += 1
Functions
def greet(name):
Built-in functions: print(), len(), type(), input(), range(), int(), float(), str()
Data Structures
Exception Handling
try:
result = 10 / 0
except ZeroDivisionError:
import math
print(math.sqrt(16))
Python Basics - Beginner to Advanced
File Handling
Reading a file:
data = f.read()
Writing to a file:
f.write('Hello, world!')
Indentation in Python
return a + b
if a > b:
print('A is greater')