Python Certification: Variables, Data Types, and Built-in Functions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

flashcard set

Earn XP

Description and Tags

Flashcards covering variables, common data types (int, float, str, bool), dynamic typing, and the print(), type(), and isinstance() built-in functions in Python.

17 Terms

1
New cards

What does it mean that Python is a dynamically typed programming language?

It means you do not have to manually specify a variable's data type when creating it; Python automatically determines the data type based on the assigned value.

2
New cards

Can a variable in Python change its data type after its initial assignment?

Yes. A variable can later be assigned a value of a different data type (for example, reassigning a variable holding the integer 25 to the string 'Twenty-five').

3
New cards

What is the key difference between the integer and float data types in Python?

Integers are whole numbers without decimals (such as 10 or -5), whereas floats are numbers with decimal points (such as 4.41, 4.50, or -0.4).

4
New cards

How is a string defined in Python?

A string is a sequence of characters enclosed in either single (') or double (") quotation marks.

5
New cards

What values can the Boolean data type have in Python?

A Boolean value is written as either True or False.

6
New cards

What is the terminal in Python programming?

The terminal is the area where you can see text output from a program.

7
New cards

What is the purpose of Python's built-in print() function?

The print() function sends text and other values to the terminal.

8
New cards

What is the output when print('Hello', 'world!') is executed?

Hello world!

9
New cards

Why does print('My favorite colors are', 'blue', 'green', 'red') output all items separated by spaces on a single line?

Because separating values with commas when passing arguments into the print() function automatically adds spaces between them.

10
New cards

What will be the output of print(type(developer)) if developer = 'Devin'?

11
New cards

What error message is produced if no arguments are passed to the type() function?

TypeError: type() takes 1 or 3 arguments

12
New cards

What does print(type(my_boolean_var)) output if my_boolean_var = True?

13
New cards

What error occurs when attempting mathematical division on a string and an integer, such as '12' / 2?

TypeError: unsupported operand type(s) for /: 'str' and 'int'

14
New cards

Which built-in Python function is used to verify whether a variable matches a specific data type?

isinstance()

15
New cards

What does isinstance(account_balance, int) return if account_balance = '12'?

False, because account_balance is assigned a string value.

16
New cards

How can you check if a variable belongs to one of multiple data types using isinstance()?

By passing a tuple of types as the second argument, such as isinstance(account_balance, (int, float)).

17
New cards

What does isinstance(account_balance, (int, float)) return when account_balance = 12?

True, because account_balance is an integer, which is one of the specified types in the tuple.