Code icon

The App is Under a Quick Maintenance

We apologize for the inconvenience. Please come back later

Menu iconMenu iconData Analysis Foundations with Python
Data Analysis Foundations with Python

Chapter 2: Getting Started with Python

2.4 Practical Exercises for Chapter 2: Getting Started with Python

Exercise 1: Install Python

If you haven't already, follow the instructions in Section 2.1 to install Python on your computer. Verify the installation by running python --version (Windows) or python3 --version (Mac/Linux) in your terminal.

Exercise 2: Your First Python Script

Create a Python script named hello.py and write code to print "Hello, world!" when run. Execute the script from your terminal.

# Expected Output
Hello, world!

Exercise 3: Working with Variables

  1. Create a variable named name and assign it your name as a string.
  2. Create a variable named age and assign it your age as an integer.
  3. Print a sentence using these variables like: "My name is [Your Name], and I am [Your Age] years old."

Exercise 4: Type Conversion

  1. Create a string variable string_number with the value "25".
  2. Convert this string into an integer and store it in a new variable integer_number.
  3. Multiply integer_number by 4 and print the result.

Exercise 5: Explore Data Types

  1. Create a list named fruits with some of your favorite fruits.
  2. Create a boolean variable is_student and set it to either True or False based on your current student status.
  3. Print all these variables and their types using print() and type().

Example:

print(fruits, type(fruits))
print(is_student, type(is_student))

Exercise 6: Variable Naming

Create variables following the best practices described in Section 2.3. Store different types of data in them and print them out. Avoid using Python's reserved words for your variable names.

2.4 Practical Exercises for Chapter 2: Getting Started with Python

Exercise 1: Install Python

If you haven't already, follow the instructions in Section 2.1 to install Python on your computer. Verify the installation by running python --version (Windows) or python3 --version (Mac/Linux) in your terminal.

Exercise 2: Your First Python Script

Create a Python script named hello.py and write code to print "Hello, world!" when run. Execute the script from your terminal.

# Expected Output
Hello, world!

Exercise 3: Working with Variables

  1. Create a variable named name and assign it your name as a string.
  2. Create a variable named age and assign it your age as an integer.
  3. Print a sentence using these variables like: "My name is [Your Name], and I am [Your Age] years old."

Exercise 4: Type Conversion

  1. Create a string variable string_number with the value "25".
  2. Convert this string into an integer and store it in a new variable integer_number.
  3. Multiply integer_number by 4 and print the result.

Exercise 5: Explore Data Types

  1. Create a list named fruits with some of your favorite fruits.
  2. Create a boolean variable is_student and set it to either True or False based on your current student status.
  3. Print all these variables and their types using print() and type().

Example:

print(fruits, type(fruits))
print(is_student, type(is_student))

Exercise 6: Variable Naming

Create variables following the best practices described in Section 2.3. Store different types of data in them and print them out. Avoid using Python's reserved words for your variable names.

2.4 Practical Exercises for Chapter 2: Getting Started with Python

Exercise 1: Install Python

If you haven't already, follow the instructions in Section 2.1 to install Python on your computer. Verify the installation by running python --version (Windows) or python3 --version (Mac/Linux) in your terminal.

Exercise 2: Your First Python Script

Create a Python script named hello.py and write code to print "Hello, world!" when run. Execute the script from your terminal.

# Expected Output
Hello, world!

Exercise 3: Working with Variables

  1. Create a variable named name and assign it your name as a string.
  2. Create a variable named age and assign it your age as an integer.
  3. Print a sentence using these variables like: "My name is [Your Name], and I am [Your Age] years old."

Exercise 4: Type Conversion

  1. Create a string variable string_number with the value "25".
  2. Convert this string into an integer and store it in a new variable integer_number.
  3. Multiply integer_number by 4 and print the result.

Exercise 5: Explore Data Types

  1. Create a list named fruits with some of your favorite fruits.
  2. Create a boolean variable is_student and set it to either True or False based on your current student status.
  3. Print all these variables and their types using print() and type().

Example:

print(fruits, type(fruits))
print(is_student, type(is_student))

Exercise 6: Variable Naming

Create variables following the best practices described in Section 2.3. Store different types of data in them and print them out. Avoid using Python's reserved words for your variable names.

2.4 Practical Exercises for Chapter 2: Getting Started with Python

Exercise 1: Install Python

If you haven't already, follow the instructions in Section 2.1 to install Python on your computer. Verify the installation by running python --version (Windows) or python3 --version (Mac/Linux) in your terminal.

Exercise 2: Your First Python Script

Create a Python script named hello.py and write code to print "Hello, world!" when run. Execute the script from your terminal.

# Expected Output
Hello, world!

Exercise 3: Working with Variables

  1. Create a variable named name and assign it your name as a string.
  2. Create a variable named age and assign it your age as an integer.
  3. Print a sentence using these variables like: "My name is [Your Name], and I am [Your Age] years old."

Exercise 4: Type Conversion

  1. Create a string variable string_number with the value "25".
  2. Convert this string into an integer and store it in a new variable integer_number.
  3. Multiply integer_number by 4 and print the result.

Exercise 5: Explore Data Types

  1. Create a list named fruits with some of your favorite fruits.
  2. Create a boolean variable is_student and set it to either True or False based on your current student status.
  3. Print all these variables and their types using print() and type().

Example:

print(fruits, type(fruits))
print(is_student, type(is_student))

Exercise 6: Variable Naming

Create variables following the best practices described in Section 2.3. Store different types of data in them and print them out. Avoid using Python's reserved words for your variable names.