Data Science Foundations
(Python)
Objective:
• Install Python and set up a development environment.
• Learn the basics of Python through hands-on coding.
• Complete assignment to reinforce learning.
by Francis Saa-Dittoh
Installing Python & Choosing an
Editor
Install Python
Download Python from [Link] (Ensure version 3.x).
During installation, check the box that says "Add Python to
PATH".
Verify installation by running:
python --version
Choose a Python Development Environment
Jupyter Notebook IDLE VS Code
Best for interactive learning Comes with Python Best for general coding
Install via: Open IDLE (installed with Python by Download from
default). [Link]
pip install jupyterlab pandas numpy
matplotlib Write Python code in the script Install the Python extension and
editor and run it. open a .py file to start coding.
Run:
jupyter notebook
Or install your preferred IDE
Printing and Variables
Printing and Variables
Variables store data, and print() displays output.
name = "Alice"
age = 23
print(f"Hello, my name is {name} and I am {age}
years old.")
Data Types
Variable Value Data Type
x 10 Integer
y 3.14 Float
z "Python" String
a True Boolean
Python has different types of data like integers, floats, and strings.
x = 10 # Integer
y = 3.14 # Float
z = "Python" # String
a = True # Boolean
print(type(x), type(y), type(z), type(a))
Lists and Loops
Create List
numbers = [1, 2, 3, 4, 5]
Loop Through Items
for num in numbers:
Process Each Item
print(num * 2)
Result
2, 4, 6, 8, 10
Lists store multiple items, and loops allow iteration.
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num * 2) # Multiply each by 2
Conditional Statements
Input
1 score = 75
Condition
2 if score >= 50:
Result
3 Print "Pass"
if statements let us make decisions in code.
score = 75
if score >= 50:
print("Pass")
else:
print("Fail")
Functions
Function Body
2 return f"Hello, {name}!"
Define Function
1
def greet(name):
Call Function
print(greet("Alice"))
3
Functions group reusable code.
def greet(name):
return f"Hello, {name}!"
print(greet("Alice"))
Assignment: Basics of Python
1 Ask for user input
Ask the user for their name and age.
2 Store in variables
Store them in variables.
3 Create message
Print a message like: "Hello [name], you are [age] years old."
4 Check age condition
If the age is below 18, print "You are a minor." Otherwise, print "You are an
adult."
Write a Python script that completes the steps above.
Submit to [Link] by Midnight of Sunday, 16th March
2025