Data: Types, Values, Variables, and Names Answers

Contents

Data: Types, Values, Variables, and Names Answers#

Drill#

 1# Create a variable named pi and assign a value to it.
 2pi = 3.14159
 3
 4# Create a variable named gpa and assign a value to it.
 5gpa = 3.8
 6
 7# Create a variable named num_fingers and assign a value to it.
 8num_fingers = 10
 9
10# Create a variable named is_open and assign a value to it.
11is_open = True
12
13# Create a variable named country and assign a value to it.
14country = "USA"
15
16# Create a variable named year and assign a value to it.
17year = 2023
18
19# Create a variable named first_name and assign a value to it.
20first_name = "John"
21
22# For each of the variables created, print the value to the console.
23print(pi)
24print(gpa)
25print(num_fingers)
26print(is_open)
27print(country)
28print(year)
29print(first_name)
30
31# Verify the type with the built-in function type()?
32print(type(pi))
33print(type(gpa))
34print(type(num_fingers))
35print(type(is_open))
36print(type(country))
37print(type(year))
38print(type(first_name))
3.14159
3.8
10
True
USA
2023
John
<class 'float'>
<class 'float'>
<class 'int'>
<class 'bool'>
<class 'str'>
<class 'int'>
<class 'str'>