zuai-logo

What are the differences between integers and floats?

Integers: Whole numbers | Floats: Numbers with decimal points.

Flip to see [answer/question]
Flip to see [answer/question]

All Flashcards

What are the differences between integers and floats?

Integers: Whole numbers | Floats: Numbers with decimal points.

What are the differences between strings and lists?

Strings: Immutable sequences of characters | Lists: Mutable ordered collections of items.

What are the differences between assignment and reassignment?

Assignment: Giving a variable a value for the first time | Reassignment: Changing the value of an existing variable.

What are the differences between local and global variables?

Local: Accessible only within the function/block where defined | Global: Accessible throughout the entire program.

What are the differences between True and False in boolean context?

True: Represents a condition that is met or satisfied | False: Represents a condition that is not met or not satisfied.

What are the differences between single quotes and double quotes for strings in Python?

Single quotes: Used to define simple strings | Double quotes: Also used to define strings, allow embedding single quotes without escaping.

What are the differences between mutable and immutable data types?

Mutable: Can be changed after creation (e.g., lists) | Immutable: Cannot be changed after creation (e.g., strings, tuples).

What are the differences between == and is operators in Python?

==: Checks if the values are equal | is: Checks if the objects are the same (same memory location).

What are the differences between explicit and implicit type conversion?

Explicit: Manually converting a data type using functions like int(), str() | Implicit: Automatic conversion performed by the interpreter.

What are the differences between an empty string and a None value?

Empty string: A string with zero characters ("") | None: Represents the absence of a value or a null value.

What is a variable?

A named storage location in computer memory that holds a value.

What is assignment?

Giving a variable a value for the first time.

What is reassignment?

Changing the value of a variable after it has already been assigned.

What are data types?

Categories that classify the type of value a variable can hold.

What is an integer (int)?

A whole number (positive or negative) without a decimal point.

What is a float?

A number with a decimal point.

What is a string (str)?

A sequence of characters enclosed in quotation marks.

What is a boolean (bool)?

A data type representing truth values: True or False.

What is a list?

An ordered collection of items, potentially of different data types, enclosed in square brackets.

What is hand tracing?

Manually stepping through code and keeping track of variable values to understand program execution.

What does the following code output?

python
x = 10
y = x + 5
x = 20
print(y)```

15

What does the following code output?

python
name = "Alice"
age = 30
print("Hello, " + name + ". You are " + str(age) + " years old.")```

Hello, Alice. You are 30 years old.

What does the following code output?

python
x = True
y = False
print(x and y)```

False

What does the following code output?

python
numbers = [1, 2, 3, 4, 5]
print(numbers[2])```

3

What does the following code output?

python
x = 5
if x > 0:
    print("Positive")
else:
    print("Non-positive")```

Positive

Identify the error in the following code:

python
pi = 3.14
print("The value of pi is: " + pi)```

TypeError: can only concatenate str (not "float") to str. The float variable pi needs to be converted to a string using str(pi) before concatenation.

Identify the error in the following code:

python
count = 5
if Count > 0:
    print("Valid")```

NameError: name 'Count' is not defined. Variable names are case-sensitive; 'Count' is different from 'count'.

What does the following code output?

python
my_list = [10, 20, 30]
my_list[1] = 25
print(my_list)```

[10, 25, 30]

What does the following code output?

python
x = 7
x = x * 2 + 1
print(x)```

15

What does the following code output?

python
flag = False
if not flag:
    print("Flag is False")```

Flag is False