top of page

Python Practice Set (Part 3): Variables & Data Types

Python Series Logo
Python Series Logo

Welcome to our next Python practice set! The absolute foundation of any programming language is understanding how to store and manage information. In Python, we do this with variables and data types. This workout is designed to solidify your understanding of core types like strings, integers, floats, lists, and dictionaries. Let's get started!


1. Full Name Greeting (Strings)


Declare two string variables: first_name and last_name. Assign your own name to them. Create a third variable, full_name, by concatenating (joining) the first and last names with a space in between. Finally, print a greeting that says, "Welcome, [Your Full Name]!".


2. Simple Grocery Calculator (Integers & Floats)


Imagine you're at a grocery store. Create a variable item_price and set it to a floating-point number (e.g., 4.99). Create another variable quantity and set it to an integer (e.g., 3). Calculate the total_cost by multiplying the price by the quantity. Print the result in a clear message, like "The total cost for 3 items is 14.97."


3. Your Top Hobbies (Lists)


Create a list called hobbies containing three of your favorite hobbies as strings.

  1. Print the entire list.

  2. Use an index to print your second favorite hobby from the list.

  3. Add a new hobby to the end of your list using the .append() method.

  4. Print the final, updated list.


4. Movie Information Card (Dictionaries)


Create a dictionary named favorite_movie to store information about a movie. Include the following key-value pairs:

  • title: The movie's title (string)

  • release_year: The year it was released (integer)

  • rating: Its rating out of 10 (float, e.g., 8.7)

  • is_watched: A boolean (True or False) indicating if you've seen it.

Print the movie's title and its rating from the dictionary.


5. Dynamic Profile Summary (Mixed Types & F-Strings)


Create three variables: name (string), age (integer), and height_meters (float). Combine these into a single descriptive string called profile_summary using an f-string. The final string should read, for example: "Profile: Alex is 30 years old and is 1.8 meters tall." Print the profile_summary.



Comments


bottom of page