Skip to content

Latest commit

 

History

History
46 lines (37 loc) · 2.39 KB

File metadata and controls

46 lines (37 loc) · 2.39 KB

Module 2: Variables and Data Types

Activity 1: What are variables?

  • Understanding what variables are and their importance in programming.
  • Exploring the concept of variables as containers for storing and manipulating data.
  • Learning about variable naming conventions and best practices.

Activity 2: Declaring and assigning variables

  • Learning how to declare variables in Python.
  • Understanding variable assignment and the use of the assignment operator =.
  • Exploring different ways to assign values to variables, including literals and expressions.

Activity 3: Data types in Python

  • Exploring the different data types available in Python, including:
    • Numeric types: Integers, floating-point numbers, and complex numbers.
    • Strings: Manipulating and concatenating strings.
    • Booleans: Working with True and False values.
    • None: Understanding the special None value.
    • Lists: Introduction to lists and their operations.
    • Dictionaries: Introduction to dictionaries and key-value pairs.
  • Understanding type inference and explicit type declarations in Python.

Practice Exercises:

  1. Calculate the area of a rectangle:

    • Declare two variables, width and height, and assign them appropriate values.
    • Calculate the area of the rectangle by multiplying width and height.
    • Store the result in a variable called area.
    • Finally, print the value of area.
  2. Concatenate strings:

    • Declare two variables, first_name and last_name, and assign them your first and last name, respectively.
    • Create a new variable called full_name and concatenate first_name and last_name.
    • Finally, print the value of full_name.
  3. Determine the data type:

    • Declare a variable called data and assign it a value of your choice.
    • Use the type() function to determine the data type of data.
    • Finally, print the result.

Estimated time to complete this module is approximately 4-6 hours.

To further enhance your learning, here are some additional resources: