0% found this document useful (0 votes)
13 views3 pages

Data Types of Python Answer Key

The document provides an overview of data types in Python, including definitions and examples of int, float, str, and bool. It includes a fill-in-the-blank section and multiple-choice questions to reinforce understanding. Additionally, it contains Python code snippets demonstrating the creation and manipulation of these data types.

Uploaded by

jesnariyas1992
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)
13 views3 pages

Data Types of Python Answer Key

The document provides an overview of data types in Python, including definitions and examples of int, float, str, and bool. It includes a fill-in-the-blank section and multiple-choice questions to reinforce understanding. Additionally, it contains Python code snippets demonstrating the creation and manipulation of these data types.

Uploaded by

jesnariyas1992
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

Answer key

✅ Section A: Definitions
 Define data type in Python:
A data type in Python defines the kind of value a variable can hold,
such as numbers, text, or True/False.
 Four basic data types in Python:
int, float, str, bool
 Type of data an integer (int) stores:
Whole numbers (e.g., 5, -3, 100)
 Type of data a float stores:
Decimal numbers (e.g., 3.14, -0.5)
 Type of data a string (str) stores:
Text or characters (e.g., "Hello", "123")
 Two possible values for Boolean (bool):
True and False
 Data type used to store whole numbers:
int
 Data type used to store decimal numbers:
float
 Data type used to store text or characters:
str
 Data type used for True/False values:
bool

✍️ Section B: Fill in the blanks


1. int stands for integer.
2. Numbers with decimal points are called floats.
3. Text values are written inside quotes.
4. A boolean value can be either True or False.
5. "Hello" is an example of string data type.
6. 12.5 is an example of float data type.
7. False is an example of boolean data type.
8. 25 is an example of integer data type.
9. "123" is stored as a string, not a number.
10. The function used to check data type in Python is type().

🧠 Section C: Multiple Choice Answers

Q# Answer
1 c) 10.0
2 c) str
3 c) True
4 b) bool
5 c) str
6 d) 7
7 c) type()
8 c) number

💻 Section D: Python Code


1. Create a variable for each data type and print them:

age = 13 # int
height = 5.4 # float
name = "Ali" # str
is_student = True # bool

print(age)
print(height)
print(name)
print(is_student)

2. Add two integer numbers:

a = 10
b = 20
sum = a + b
print("Sum:", sum)
3. Find the average of two float numbers:

x = 12.5
y = 15.5
average = (x + y) / 2
print("Average:", average)

4. Store your name and print a greeting:


name = "Ali"
print("Hello,", name + "!")

5. Boolean variable and conditional message:

is_student = True

if is_student:
print("Welcome, student!")
else:
print("Welcome, guest!")

You might also like