Data Types

Python has different data types for storing data in different formats. Based on the type of data that something is, there are different ways the data can be manipulated.
Data types cannot be mixed. If something is a certain data type, you can't add another piece of data to it with a different data type. The most common ones you will see are strings, integers, floats, lists, tuples, dictionaries, booleans, and bytes. For this class, we are going to focus on strings, integers, and booleans.
Strings
Strings are data types that store characters. A string is denoted by quotes, anything in quotes will be considered a string. You can use single or double quotes, but whichever ones that you use, they have to be the same on both sides.
"Hello"
is a string because it is in quotes. "4"
is also a string because it
is in quotes. However, 4
is not a string because there are no quotes around it. The computer
sees it as an actual number.
If you try adding two strings together, you will get the two strings next to each other. For example,
if you say print("Hello" + "Bob")
, you will get HelloBob
as your output. Same
thing goes for string numbers: if you say print("2" + "2")
, your output will be 22
.
Integers
The other most commonly used data type is the integer. This is your typical number that you can do mathematical operations on. A number on its own is considered an integer, they don't have quotes surrounding them.
If you try doing print(2 + 2)
, since there are no quotes here, the computer will see this
as actual numbers and will actually add the two numbers together. Your output in this case would be 4
.
Booleans
Booleans are comparison operators that are used to control computer logic(we will get more into this later). There
are only two Boolean values in Python: True
and False
. When you compare two values,
the expression is evaluated and Python returns the Boolean answer.
For example, you can compare numbers: print(9 > 10)
will return True because that is a true/correct
statement. However, if you say print(9 == 10)
, False will be returned because that is incorrect/false.
Figuring Out Data Types
There is a Python function, type, that will tell you what the data type of something is. If you say print(type("hello"))
,
your output will be str
, which means the argument was a string. Similarly, if you say print(type(2))
,
the function will return int
, signifying that the input was an integer.
Mad Libs
To practice with different data types, today we will be making a mad-libs game. Below is the program code:
noun1 = input("Give a noun: ")
noun2 = input("Give another noun: ")
verb1 = input("Give a verb ending in -ing: ")
verb2 = input("Give another verb ending in -ed: ")
adjective = input("Give an adjective: ")
print("The", adjective, noun1, "was", verb1, "happily through the woods when it suddenly", verb2, "over the", noun2)
The first 5 lines of this program are asking the user for different figures of speech, all of which are being
collected as strings. The input function asks the user for input, and stores it in the variable it is assigned
to. For example, in the first line, the user is being asked for a noun, and the noun that the user gives is being
stored in the variable noun1
. If you test the type of data for noun1(type(noun1)
) will
return str
because input always collects input in string form.
The last line of the program concatenates(adds) the provided strings to some strings already decided to create the mad lib. In this case, commas are being used to separate the strings and variables from each other.
When you run this program in Replit, it should look something like this:

Greeting Program
Your assignment for today is to make a greeting program. It will welcome the user, ask for their name, and then greet them using their name. Below are the instructions:
- Create a file named "welcome.py"
- Say hello to the user
- Ask the user for their na,e and store the name in a variable
- Using that variable, greet them by name, something along the lines of "Hi ______, nice to meet you!
Here is an example of what your output should look like:
