Week 1
Week 1
2. Introduction to Tools
Google Colab
A cloud-based platform for writing and executing Python code.
Supports GPU/TPU for resource-intensive tasks.
Use Runtime -> Change Runtime Type to switch to GPU/TPU [1] .
Replit
A browser-based IDE for coding collaboratively.
Features include real-time previews, AI-assisted debugging, and GitHub integration [2] .
3. Python Basics
Input Statements
Use input() to take user input:
name = input("Enter your name: ")
print("Hello", name)
Data Types
Common data types in Python:
Data Type Example
int x = 10
float x = 3.14
str x = "Hello"
list x =[^1][^2][^3]
tuple x = (1, 2, 3)
Arithmetic Operators
Perform mathematical operations:
a, b = 5, 2
print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division
print(a % b) # Modulus
Comparison Operators
Compare values:
print(5 > 3) # True
print(5 == 3) # False
Logical Operators
Combine conditions:
print(True and False) # False
print(True or False) # True
String Operations
Concatenation: "Hello" + " World"
5. Strings
Output:
<class 'int'>
<class 'str'>
<class 'bool'>
2. Create a dictionary:
x = True
y = False
print(x or y) # True
print(x and y) # False
s = "Python"
print(s[::-1]) # Output: nohtyP
s = "google.com"
freq = Counter(s)
print(freq)
Output:
{'g':2, 'o':3, 'l':1, 'e':1, '.':1, 'c':1, 'm':1}
# Reverse alphabet:
print(ascii_uppercase[::-1]) # ZYXWVUTSRQPONMLKJIHGFEDCBA
These notes and practice problems cover all the essential concepts from Week 1 of your course
structure.
⁂
1. https://www.marqo.ai/blog/getting-started-with-google-colab-a-beginners-guide
2. https://docs.replit.com/getting-started/intro-replit
3. https://www.programiz.com/python-programming/variables-constants-literals
4. https://pynative.com/python-data-types/
5. https://www.w3schools.com/python/python_datatypes.asp
6. https://realpython.com/python-operators-expressions/