SkyLimit Tech Hub: Data Science Training Center

Course 1: Python Basics — Syntax, Variables & Control Flow

This course is designed to introduce learners to the fundamentals of Python programming, focusing on its syntax, variables, and control flow structures. Spanning one week, the course includes daily lessons covering introductions, objectives, scopes, background information, examples, supplemental resources, and quizzes. It provides a strong foundation for beginners to build technical skills in programming and data analysis.

Objective: By the end of the course, students will be able to write basic Python programs, manage variables, perform operations, and implement control flow using conditionals and loops.

Scope: The course covers Python installation, basic syntax, variable management, operators, conditional statements, and loops, preparing learners for more advanced Python concepts.

Day 1: Introduction to Python Programming

Introduction: Python is a versatile, high-level programming language known for its simplicity, readability, and flexibility. Its clean and straightforward syntax makes it an ideal starting point for beginners, while its extensive ecosystem of libraries and frameworks supports advanced applications across fields like web development, automation, machine learning, and, notably, data analysis. Learning Python lays a strong foundation for more complex technical skills.

Learning Objective: The goal for today's lesson is to introduce learners to Python’s basic syntax, guide them through setting up a working environment, and help them understand the structure of simple Python programs. Learners will be able to write their first lines of code confidently and grasp the role of variables and data types in Python.

Scope of the Lesson: Today’s topics include installing Python, setting up an Integrated Development Environment (IDE) like Jupyter Notebook or VS Code, understanding and applying correct syntax practices (including the use of comments and indentation), and gaining a high-level overview of variables and common data types (integers, floats, strings, and Booleans).

Background Information: Python was created by Guido van Rossum and released in 1991 with a focus on code readability and minimalism. Unlike many languages, Python does not use curly braces {} or semicolons ; to delimit code blocks—instead, it uses consistent indentation (typically 4 spaces per level). Comments, written using the # symbol, are vital for code documentation. Python's dynamic typing system means variables are created upon assignment without declaring a type, which accelerates prototyping and exploration, especially for data articulacy and analysts.

Examples to Practice:

# Example 1: Adding a comment and printing a simple message
# This is a comment
print("Hello, Python World!")

# Example 2: Demonstrating correct indentation in Python
if 5 > 2:
    print("Five is greater than two.")

# Example 3: Assigning values to variables and printing them
language = "Python"
version = 3.10
is_fun = True
print(language)
print(version)
print(is_fun)

# Example 4: Running a basic Python script in Jupyter Notebook
# (In Jupyter, each cell can run individually)
message = "Running in Jupyter!"
print(message)
                

Explanation of the Example Codes & Outputs: In Example 1, a simple comment is added, and a message is printed. Example 2 shows the use of indentation inside an if statement, which is crucial in Python for defining blocks. Example 3 assigns values of different types (string, float, Boolean) to variables and displays them. Example 4 demonstrates how scripts are run in a Jupyter environment, where each code block can be executed independently. All examples show Python's simple, readable syntax and reinforce its dynamic typing.

Supplemental Information: Beginners should pay special attention to correct indentation and the use of comments to improve code readability. Watching Corey Schafer’s "Python for Beginners" series provides a clear and practical introduction to Python coding. Additionally, Python for Data Analysis by Wes McKinney is a cornerstone reference for anyone moving from basic programming into real-world data manipulation and analytics.

Resources:

Day 2: Variables and Data Types

Introduction: Variables act as containers for storing data values, allowing programs to perform operations, transformations, and analyses. In Python, variables can hold different data types such as integers, floats, strings, and Booleans, each serving distinct roles in computational tasks. Understanding how to effectively work with variables is fundamental to writing dynamic and efficient Python scripts.

Learning Objective: Today's goal is to help learners create, name, and manage variables properly while gaining a clear understanding of Python’s core data types. By the end of the lesson, learners should be able to assign values, perform type checking, and convert between types when needed.

Scope of the Lesson: We will explore best practices for naming variables, how to assign and reassign values, the major data types (int, float, str, bool), and basic input/output interactions. In addition, we will practice converting data between types and verifying data types using the type() function.

Background Information: In Python, variables are declared by simple assignment using the = operator without explicitly mentioning their data type. The language follows loose typing, meaning a variable can later be reassigned to a value of a different type if needed. It is important to follow naming conventions: use descriptive names, lowercase letters, underscores to separate words, and avoid using Python's reserved keywords (such as for, class, if). Python provides useful built-in functions such as int(), float(), str(), and bool() for type conversion and the type() function for checking the current type of a variable.

Examples to Practice:

# Example 1: Creating variables of different data types
age = 25          # integer
height = 5.9      # float
name = "Alice"    # string
is_student = True # boolean

# Example 2: Using type() function to check variable types
print(type(age))
print(type(height))
print(type(name))
print(type(is_student))

# Example 3: Performing type conversion
age_str = str(age)      # convert integer to string
height_int = int(height) # convert float to integer
student_status = str(is_student)  # boolean to string
print(age_str, height_int, student_status)

# Example 4: Taking user input and converting types
user_input = input("Enter your age: ")  # always returns string
user_age = int(user_input)  # converting string to integer
print(f"You will be {user_age + 1} years old next year.")
                

Explanation of the Example Codes & Outputs: In Example 1, different variables are assigned values of various core types. Example 2 uses type() to display the data type of each variable, confirming they match expectations. Example 3 demonstrates how to convert data from one type to another using built-in functions, which is crucial when handling user inputs or performing calculations. Example 4 introduces input(), showing how user input (always a string) must often be converted for numeric operations. Each example highlights Python's flexible and dynamic handling of variables and types.

Supplemental Information: A strong grasp of Python’s variable system is crucial for further topics like data structures and data manipulation. Beginners should practice creating and converting variables until it feels natural. Watching Tech With Tim’s Python Variables and Data Types tutorial will visually reinforce today's material. For a deeper understanding of data handling, Python Data Science Handbook by Jake VanderPlas is a highly recommended resource.

Resources:

Day 3: Operators and Expressions

Introduction: Operators are essential building blocks in Python that enable manipulation and evaluation of data. Through arithmetic, comparison, and logical operations, operators empower programmers to perform calculations, check conditions, and control the flow of a program. Mastery of operators leads to writing efficient and powerful expressions critical for real-world data analysis tasks.

Learning Objective: Today's objective is to familiarize learners with different types of Python operators and how to use them effectively in expressions. By the end of this lesson, learners should confidently perform calculations, compare values, and create logical statements to control program logic.

Scope of the Lesson: This lesson covers arithmetic operators (+, -, *, /, //, %, **), comparison operators (==, !=, >, <, >=, <=), logical operators (and, or, not), and operator precedence rules. We will also explore how to combine operators into complex expressions that evaluate multiple conditions or perform multi-step calculations.

Background Information: In Python, operators manipulate variables and values. Arithmetic operators perform basic mathematical operations like addition and division. Comparison operators compare two values and return a Boolean result (True or False). Logical operators combine multiple Boolean expressions, allowing complex condition evaluations. Understanding operator precedence is important; Python evaluates expressions following the PEMDAS rule, but parentheses can be used to control evaluation order explicitly for clarity and accuracy.

Examples to Practice:

# Example 1: Basic arithmetic operations
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

# Example 2: Comparison operators
x = 5
y = 10
print(x == y)   # False
print(x != y)   # True
print(x > y)    # False
print(x < y)    # True

# Example 3: Logical operators
is_sunny = True
is_weekend = False
print(is_sunny and is_weekend)  # False
print(is_sunny or is_weekend)   # True
print(not is_weekend)           # True

# Example 4: Operator precedence
result = 5 + 2 * 3
print(result)  # 11, multiplication happens first
result_with_parentheses = (5 + 2) * 3
print(result_with_parentheses)  # 21, addition first
                

Explanation of the Example Codes & Outputs: In Example 1, we perform basic mathematical operations, showcasing how each arithmetic operator works. Example 2 uses comparison operators to evaluate relationships between numbers, resulting in True or False. Example 3 demonstrates logical operations that combine Boolean values. Finally, Example 4 highlights the importance of operator precedence: Python calculates multiplication before addition unless parentheses are used to override the order. These examples reinforce the fundamental concepts needed to write complex expressions in Python.

Supplemental Information: A solid understanding of operators is vital for conditional logic, loops, and mathematical modeling in Python. Misunderstanding operator precedence can lead to logical errors, so careful use of parentheses is encouraged. The "Python Operators" video by Programming with Mosh provides clear visual explanations for beginners. For more in-depth study, Python Machine Learning by Raschka and Mirjalili offers real-world examples applying operators in advanced machine learning algorithms.

Resources:

Day 4: Control Flow: Conditionals

Introduction: Control flow structures such as if, elif, and else are fundamental tools that allow Python programs to make decisions based on specific conditions. They enable the dynamic execution of code, allowing programs to react differently depending on varying input or circumstances. This makes conditional logic essential for creating flexible, responsive scripts, especially in the field of data analysis.

Learning Objective: Today's goal is to understand and implement conditional statements using if, elif, and else blocks. Learners will practice evaluating conditions, building decision-making logic, and writing nested structures that mirror real-world decision trees.

Scope of the Lesson: This lesson covers the syntax and structure of if, elif, and else statements, the importance of indentation in Python, how to use logical operators to combine multiple conditions, and how to build nested conditionals for complex decision-making scenarios. Clear understanding of these structures is vital for controlling program execution based on dynamic data.

Background Information: In Python, conditional statements evaluate Boolean expressions to determine which code block should be executed. The if statement checks a condition, and if it evaluates to True, the indented block underneath it runs. If the if condition fails, elif allows for checking other conditions, while else provides a fallback. Indentation (typically four spaces) is mandatory to indicate block structure. Nested conditionals allow more granular decision-making, and logical operators like and, or, and not enable combining multiple Boolean expressions into a single condition.

Examples to Practice:

# Example 1: Simple if-else statement
temperature = 30
if temperature > 25:
    print("It's a hot day")
else:
    print("It's a cool day")

# Example 2: if-elif-else ladder
score = 85
if score >= 90:
    print("Grade: A")
elif score >= 80:
    print("Grade: B")
elif score >= 70:
    print("Grade: C")
else:
    print("Grade: D or F")

# Example 3: Nested conditionals
age = 20
has_id = True
if age >= 18:
    if has_id:
        print("Access granted")
    else:
        print("ID required for entry")
else:
    print("Access denied: underage")

# Example 4: Combining conditions with logical operators
income = 45000
credit_score = 720
if income > 40000 and credit_score > 700:
    print("Loan approved")
else:
    print("Loan denied")
                

Explanation of the Example Codes & Outputs: In Example 1, a simple if-else evaluates the temperature and prints a message accordingly. Example 2 expands the logic using an if-elif-else ladder to categorize a numerical score into a grade. Example 3 demonstrates nested if statements, where the second condition (has_id) is only checked if the first (age >= 18) is true. Example 4 shows how logical operators combine multiple conditions to make a single decision. These examples reflect real-world scenarios like eligibility checking, grading systems, and access control.

Supplemental Information: Understanding control flow is crucial for writing programs that can react intelligently to changing inputs. Poorly structured conditionals can lead to logical errors and unintended program behavior, so attention to indentation and logical clarity is critical. The "Python Conditionals" video by FreeCodeCamp offers visual explanations and practice problems that are very helpful for beginners. For a deeper dive, Python for Data Analysis by Wes McKinney provides practical examples involving data-driven decision-making in real datasets.

Resources:

Day 5: Control Flow: Loops

Introduction: Loops, specifically for and while, are powerful tools that automate repetitive tasks in programming. They are especially useful in data analysis, where tasks such as iterating over datasets or applying functions to large collections of data are common. By using loops, you can save time, reduce errors, and increase the efficiency of your programs.

Learning Objective: The goal of this lesson is to help learners master the use of for and while loops, enabling them to iterate over sequences (such as lists and ranges) and control the flow of execution in their code. You'll also learn how to manage loop execution with control statements such as break and continue.

Scope of the Lesson: This lesson covers the use of for loops, which are ideal for iterating over sequences like lists or ranges, and while loops, which continue execution as long as a condition is met. Loop control, including break (to exit a loop early) and continue (to skip to the next iteration), will be discussed. Additionally, you'll learn how to use nested loops to handle multi-dimensional data, such as looping through rows and columns in a dataset.

Background Information: A for loop iterates over a sequence, such as a list or range, executing a block of code for each item. The range() function is commonly used in for loops to generate a sequence of numbers. On the other hand, a while loop repeatedly executes as long as a specified condition evaluates to True. Loop control statements, such as break, terminate the loop early, and continue skips to the next iteration without completing the remaining code in the current loop. Nested loops are useful when you need to iterate through multi-dimensional structures like lists of lists or data tables.

Examples to Practice:

# Example 1: Simple for loop
for i in range(5):
    print(f"Iteration {i}")

# Example 2: while loop
x = 0
while x < 5:
    print(f"Value of x: {x}")
    x += 1

# Example 3: Using break to exit a loop early
for i in range(10):
    if i == 5:
        break
    print(i)

# Example 4: Using continue to skip an iteration
for i in range(5):
    if i == 3:
        continue
    print(i)

# Example 5: Nested loops for multi-dimensional data
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for row in matrix:
    for element in row:
        print(element)
                

Explanation of the Example Codes & Outputs: In Example 1, the for loop iterates over the range from 0 to 4, printing each iteration number. Example 2 demonstrates a while loop that continues until x reaches 5. In Example 3, the break statement exits the loop when i equals 5. Example 4 shows the use of continue, which skips printing the number 3 in the loop. Lastly, Example 5 uses a nested loop to iterate through a two-dimensional list (matrix), printing each element in the matrix sequentially.

Supplemental Information: Mastering loops and their control structures is essential for efficient programming, especially when dealing with large datasets. You can practice these concepts further through exercises and real-life examples, such as iterating over datasets, performing calculations, or processing multiple files in data analysis tasks. Corey Schafer’s video on loops provides a detailed explanation with more practice problems. For further reading on Python and data science, refer to Python Data Science Handbook by Jake VanderPlas.

Resources:

Daily Quiz

Practice Lab

Select an environment to practice coding exercises.

Exercise

Download the following files to support your learning:

Grade

Day 1 Score: Not completed

Day 2 Score: Not completed

Day 3 Score: Not completed

Day 4 Score: Not completed

Day 5 Score: Not completed

Overall Average Score: Not calculated

Overall Grade: Not calculated

Generate Certificate

Click the button below to generate your certificate for completing the course.