Week Two: Data Types
In this second week, we dive into how Python categorizes different kinds of information without using variables yet. We will be asking and thinking about the following questions:
- What is a data type?
- What is the difference between text (strings), whole numbers (integers), decimals (floats), and true/false values (booleans)?
- How does Python recognize different values directly?
- How do we check a data type using
type()?
Presentation
Activity
In this activity, you’ll explore Python’s core data types by printing values and exploring how Python treats different kinds of information.
Concepts you will explore
- Strings (
str): Text enclosed in quotes (e.g.,"Genesis"). - Integers (
int): Whole numbers without decimals (e.g.,40). - Floats (
float): Decimal numbers (e.g.,3.5). - Booleans (
bool): True or False values representing logic (e.g.,True). - The
type()function: How to ask Python what data type a specific value is.
# Printing different data types directly
print("Book of John") # String (str)
print(12) # Integer (int)
print(7.77) # Float (float)
print(True) # Boolean (bool)Explore Further
- Try printing favorite Bible verses or chapter numbers using different data types.
- Experiment with what happens when you put numbers inside quotes versus leaving them unquoted.
Challenges
Choose your difficulty level and put your data type skills to the test!
Python Editor
The Scripture Info Printer
Write a Python program that uses print statements to display information about a Bible book using strings, integers, and booleans.
Requirements:
- Print the name of a Bible book as a string.
- Print the total number of chapters as an integer.
- Print a boolean value representing whether it is in the New Testament (
TrueorFalse).
Expected Output:
Genesis
50
New Testament: FalseView Solution
# Scripture info printer
print("Genesis")
print(50)
print("New Testament:", False)Last updated on
