0% found this document useful (0 votes)
8 views2 pages

Python Homework - Data Types

This document outlines a Python homework assignment focused on the four pillars of data: Integer, Float, String, and Boolean. It includes instructions for submission, learning objectives, and specific tasks divided into parts that require students to practice using the type() function, perform mathematical operations, manipulate strings, and understand Boolean values. The assignment emphasizes the importance of data types and their operations in Python programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Python Homework - Data Types

This document outlines a Python homework assignment focused on the four pillars of data: Integer, Float, String, and Boolean. It includes instructions for submission, learning objectives, and specific tasks divided into parts that require students to practice using the type() function, perform mathematical operations, manipulate strings, and understand Boolean values. The assignment emphasizes the importance of data types and their operations in Python programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

🐍 Python Homework: The Four Pillars of

Data
Student Name: _________________________

Date: __________________________________

📥 Submission Instructions
1.​ Separate Cells: Each Part (Part 1, Part 2, etc.) must be written and executed in its own
separate code cell in your Notebook (Google Colab or Jupyter).
2.​ Comments: Start each code cell with a comment indicating the Part number (e.g., # Part
1).
3.​ Sharing: Once complete, click the Share button at the top right. Set the access to
"Anyone with the link can view" and paste the link in the submission box.

🎯 Learning Objectives
●​ Identify the 4 core data types: Integer, Float, String, and Boolean.
●​ Use the type() function to verify data identity.
●​ Practice sequence operations (concatenation and repetition) on raw data.
●​ Observe how Python handles different data types in math operations.

📦 Part 1: The Identity Lab (type() function)


In Python, every piece of data has a "type." We use type(value) to see what it is.

Task 1.1: Write 4 separate print() statements. Inside each print(), use the type() function to
check these exact values:
1.​ Check the type of: 500
2.​ Check the type of: 99.9
3.​ Check the type of: "Coding is fun"
4.​ Check the type of: False
Task 1.2: Write a single print() statement that checks the type of a number inside quotes:
type("100"). In a comment below the code, explain if the result is an integer or a string.

🔢 Part 2: Number Precision (int vs float)


Integers are whole numbers; Floats are for decimals.

Task 2.1: Use print() to see the result and the type() of the following math operations:
1.​ print(10 + 5) and print(type(10 + 5))
2.​ print(10 + 5.0) and print(type(10 + 5.0))
Task 2.2: Python treats division uniquely. Use print() to show the result and the type() of:
1.​ 10 / 2
2.​ 20 / 4​
(Note: Even if the answer is a whole number, look closely at the type!)

💬 Part 3: String Mechanics (str)


Strings represent text and can be manipulated with math symbols.

Task 3.1: Use print() to show the result of these string operations:
1.​ "Data" + "Science" (Concatenation)
2.​ "Python " * 5 (Repetition)
Task 3.2 (The Quote Trap):
1.​ Write a print() statement that displays this exact text using single quotes on the outside:
○​ "Hello World"
2.​ Write a print() statement that displays this exact text using double quotes on the outside:
○​ 'Hello World'

⚖️ Part 4: Boolean Realities (bool)


Booleans are logical values: True or False.

Task 4.1: Use print() and type() to check these comparison results:
1.​ print(10 > 5) and print(type(10 > 5))
2.​ print(2 == 5) and print(type(2 == 5))

🎨 Part 5: The Data Summary


Task: Write 4 separate print() statements that display a label and the type of a value directly.

Expected Output Format:


●​ print("Whole Number Type:", type(100))
●​ print("Decimal Number Type:", type(10.5))
●​ print("Text Data Type:", type("Hello"))
●​ print("Logic Data Type:", type(True))

🏁 Final Thinking Question


Double-click this cell to type your answer below.

If you try to run print("5" + 5), will it work? Based on what you learned about types, why can't
Python add a string to an integer?

You might also like