Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

← Data Types, Variables, Basic I/O and Operators practice sets

PCEP Data Types, Variables, Basic I/O and Operators • Complete Question Bank

PCEP Data Types, Variables, Basic I/O and Operators — All Questions With Answers

Complete PCEP Data Types, Variables, Basic I/O and Operators question bank — all 0 questions with answers and detailed explanations.

194
Questions
Free
No signup
Certifications/PCEP/Practice Test/Data Types, Variables, Basic I/O and Operators/All Questions
Question 1easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes the following code: x = 5; y = 2; print(x // y). What is the output?

Question 2mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A junior developer writes: x = 10; y = 3; print(x % y). What will be printed?

Question 3hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to convert a string '25' to an integer and then add 10. Which code correctly performs this?

Question 4easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the correct way to read a floating-point number from user input and store it in a variable?

Question 5mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer wants to assign the value 3.14 to a variable and later change it to the integer 3. Which of the following is true?

Question 6easymultiple choice
Study the full Python automation breakdown →

Which of the following is a valid variable name in Python?

Question 7mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes: print(10 * '5'). What is the output?

Question 8hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the result of the expression: print(2 ** 3 ** 2) ?

Question 9easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A beginner writes: x = '10'; y = 20; print(x + y). What happens?

Question 10mediummultiple choice
Study the full Python automation breakdown →

Which operator is used to check if two values are equal in Python?

Question 11hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes: a = 3; b = 4; c = a + b / 2. What is the value of c?

Question 12mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following are valid ways to create a variable with the integer value 100?

Question 13hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which THREE of the following expressions evaluate to True?

Question 14easymulti select
Study the full Python automation breakdown →

Which TWO of the following are valid Python data types?

Question 15mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which THREE of the following are correct uses of the print() function?

Question 16mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the code?

Exhibit

Refer to the exhibit.

x = 7
y = 2
result = x / y
print(type(result))
Question 17hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A user enters 'Alice' for name and '30' for age. What is the output?

Exhibit

Refer to the exhibit.

name = input('Enter name: ')
age = input('Enter age: ')
print(name + ' is ' + age + ' years old.')
Question 18easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the data type of z?

Exhibit

Refer to the exhibit.

x = 10
y = 3.0
z = x * y
print(z)
Question 19hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

You are a junior developer at a logistics company. Your team is building a system to calculate shipping costs based on package weight. The system reads weight from user input. A colleague wrote the following code: weight = input('Enter weight in kg: '); cost = weight * 2.5; print('Shipping cost:', cost). However, when testing with weight 10, the output is 'Shipping cost: 10101010101010101010' (the string '10' repeated 2.5 times? Actually, 2.5 is float, but string multiplied by float causes TypeError? Wait, string * float raises TypeError. But the symptom described suggests the code runs but produces unexpected output. Let me re-read: The output shows '10101010101010101010' which is the string '10' repeated 10 times? That would happen if weight is string and multiplied by int 10. But the code multiplies by 2.5. Actually, string * float raises TypeError, so the code would crash. The symptom must be plausible. Let me adjust: The code actually has weight = input(...), then cost = weight * 2.5, but if weight is '10', then '10' * 2.5 raises TypeError. So the symptom cannot be that output. I need to fix the stem to make sense. Instead, let's say the code is: weight = input('Enter weight: '); cost = float(weight) * 2.5; print('Cost:', cost). But then no issue. I'll create a scenario where the developer forgot to convert input to float, and then tries to multiply string by float, which causes TypeError. The correct action is to convert input to float. I'll adjust the stem accordingly. Let me rewrite the stem properly.

Stem: You are a developer at a shipping company. The system calculates shipping cost as weight (kg) times rate 2.5. A colleague wrote: weight = input('Enter weight: '); cost = weight * 2.5; print('Cost:', cost). When testing with weight 10, the program crashes with TypeError. Which action should you take to fix the code?

Question 20mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

You are a data analyst at a retail company. You have a list of sales figures stored as strings in a list: sales = ['100', '200', '300']. You need to calculate the total sum. A colleague suggests using: total = sum(sales). However, this raises a TypeError because sum() requires numeric values. Which approach should you take to correctly calculate the total as an integer?

Question 21easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes a script to read the user's age and print 'Adult' if the age is 18 or above. The code outputs 'Adult' for age 17. What is the most likely cause?

Question 22mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to store the result of dividing two numbers, a/b, but only if b is not zero. They write: result = a / b if b != 0 else 'undefined'. What is the data type of result when b is zero?

Question 23hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A script calculates total cost: price = 49.95, quantity = 3, tax_rate = 0.08. The developer writes: total = price * quantity * (1 + tax_rate). The result is printed as 161.838. Which best practice is being violated?

Question 24mediummulti select
Study the full Python automation breakdown →

Which TWO of the following are valid variable names in Python? (Choose two.)

Question 25mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the code in the exhibit?

Exhibit

Refer to the exhibit.

>>> x = 10
>>> y = 3
>>> z = x // y
>>> print(z)
Question 26hardmultiple choice
Study the full Python automation breakdown →

You are maintaining a legacy Python 2.7 script that calculates shipping costs. The script reads weight from user input, then calculates cost as weight * 1.5. Recently, the company upgraded to Python 3.9, and now the script raises a TypeError: can't multiply sequence by non-int of type 'float'. The input line is: weight = input('Enter weight: '). You need to fix the script minimally. Which action should you take?

Question 27easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes a script to read user input using input() and then prints it. However, the program crashes when the user enters a number. What is the most likely cause?

Question 28mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program calculates the total price including tax: total = price * 1.08. The variable price is assigned as price = 100.0. After execution, total is 108.0. The developer then changes price to 100. What will total be?

Question 29hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to store a large collection of unique user IDs (integers) and quickly check if a new ID already exists. Which data type is most appropriate for this task?

Question 30easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A programmer writes: x = 5; y = x; x = 3; print(y). What is the output?

Question 31mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer wants to read a floating-point number from user input and compute its square. Which code snippet correctly accomplishes this?

Question 32hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A script uses the // operator with negative numbers. For example, -7 // 2 returns -4. The developer expected -3. Which statement best explains this behavior?

Question 33easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes a program to calculate the average of three numbers: a=10; b=20; c=30; avg = a + b + c / 3; print(avg). What is the output?

Question 34mediummultiple choice
Study the full Python automation breakdown →

A programmer needs to swap the values of two variables a and b without using a temporary variable. Which approach works in Python?

Question 35easymulti select
Study the full Python automation breakdown →

Which TWO of the following are valid variable names in Python? (Choose two.)

Question 36mediummulti select
Study the full Python automation breakdown →

Which TWO of the following expressions evaluate to True in Python? (Choose two.)

Question 37hardmulti select
Study the full Python automation breakdown →

Which THREE of the following are built-in Python data types? (Choose three.)

Question 38mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer runs the script and enters 'Alice' and '25'. What does it print?

Exhibit

Refer to the exhibit.

name = input('Enter name: ')
age = input('Enter age: ')
print(name + ' is ' + age + ' years old.')

If the user enters 'Alice' and '25', what is the output?
Question 39hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given the exhibit, what does the code print?

Exhibit

Refer to the exhibit.

x = 10.5
y = 3
result = x // y
print(result)

What is the output of this code?
Question 40mediummultiple choice
Study the full Python automation breakdown →

A company runs a Python script on a server that monitors network traffic. The script reads a configuration file containing a threshold value as a string, e.g., '0.85'. The script compares this threshold to a calculated load average (float). The developer writes: threshold = config['threshold']; if load > threshold: alert(). The alert never triggers even when load exceeds 0.85. The config file is correctly parsed. What is the most likely cause and solution?

Question 41hardmultiple choice
Study the full Python automation breakdown →

A data analyst uses Python to process a CSV file containing sales data. The file has columns: 'Product', 'Price', 'Quantity'. The analyst writes a script to compute total sales: sum of Price * Quantity for each row. The code reads each row as a list of strings. The analyst uses: total = 0; for row in reader: total += row['Price'] * row['Quantity']; print(total). The script raises a TypeError. What is the best fix?

Question 42mediumdrag order
Study the full Python automation breakdown →

Order the steps to define and call a function in Python.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 43mediumdrag order
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Order the steps to write a for loop that iterates over a range of numbers.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 44mediumdrag order
Study the full Python automation breakdown →

Order the steps to debug a Python script using print statements.

Drag steps to the numbered slots on the right, or tap a step then tap a slot.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4
5Step 5
Question 45mediummatching
Study the full Python automation breakdown →

Match each Python operator to its description.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Equality comparison operator

Inequality comparison operator

Floor division operator

Modulus (remainder) operator

Exponentiation operator

Question 46mediummatching
Study the full Python automation breakdown →

Match each Python data structure to its characteristic.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Ordered, immutable sequence of items

Unordered collection of unique items

Mapping of key-value pairs

Ordered, mutable sequence of items

Immutable sequence of characters

Question 47mediummatching
Study the full Python automation breakdown →

Match each Python control flow statement to its purpose.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Exits the current loop immediately

Skips the rest of the current iteration and goes to the next

Does nothing; used as a placeholder

Short for else-if; checks another condition

Executes a block when no previous condition is true

Question 48easymultiple choice
Study the full Python automation breakdown →

Which of the following is a valid Python variable name?

Question 49mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program uses 'x = 3.14' and 'y = int(x)'. What is the value of y?

Question 50hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given 'a = 10; b = 3; c = a // b; d = a % b', what is the value of c + d?

Question 51easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What does 'print(2 ** 3)' output?

Question 52mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

After 'x = 5; x += 3', what is the value of x?

Question 53hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the result of 'bool(0) and bool(1)'?

Question 54easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which function is used to read user input as a string?

Question 55mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of 'print(3 * "ab")'?

Question 56hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given 's = "Hello"; t = s[0:3]; print(t)', what is the output?

Question 57easymulti select
Study the full Python automation breakdown →

Which TWO of the following are valid Python variable names?

Question 58mediummulti select
Study the full Python automation breakdown →

Which THREE of the following are Python built-in data types?

Question 59hardmulti select
Study the full Python automation breakdown →

Which TWO operators in Python yield an integer result when applied to two integers?

Question 60easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. What is the cause of the error?

Exhibit

Traceback (most recent call last):
  File "script.py", line 3, in <module>
    result = "5" + 10
TypeError: can only concatenate str (not "int") to str
Question 61mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. What is the value of z?

Exhibit

>>> x = 10
>>> y = 20
>>> z = x * y + 5
>>> print(z)
205
Question 62hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. The code used is: name = input('Enter name: '); print('Hello', name). What will be printed if the user enters 'Alice'?

Exhibit

Enter name: Bob
Hello Bob
Question 63easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes the following code: result = (5 + 3) * 2 ** 3 // 4. What is the value of result?

Question 64easymultiple choice
Study the full Python automation breakdown →

Which of the following variable names is valid in Python?

Question 65mediummultiple choice
Study the full Python automation breakdown →

An accountant uses a Python script to calculate tax: tax = price * 0.08. For price=19.99, tax results in 1.5992. However, the output should be rounded to two decimal places. Which expression should replace the current one?

Question 66mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A junior developer writes: print('Hello' + 5). This code raises an error. What is the best way to fix it?

Question 67hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A script uses the input() function to get a user's age: age = input('Enter age: '). Later it computes age > 18. This raises a TypeError. What is the root cause?

Question 68easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which data type is the result of: value = 10 // 3?

Question 69mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program needs to check if a number is both positive and even. Which expression correctly implements this?

Question 70hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given the code: x = 10; y = 3.0; z = x / y; print(type(z)). What is the output?

Question 71mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer wants to output a variable price with two decimal places using formatting. Which line of code will produce 'Price: $12.50' for price = 12.5?

Question 72easymulti select
Study the full Python automation breakdown →

Which TWO of the following are valid ways to comment in Python?

Question 73mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following expressions evaluate to True?

Question 74hardmulti select
Study the full Python automation breakdown →

Which THREE of the following statements about Python operators are true?

Question 75easymultiple choice
Study the full Python automation breakdown →

Refer to the exhibit. What is the output of the Python code?

Exhibit

Refer to the exhibit.

```
>>> print(3 * 'abc')
```
Question 76mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. Which of the following shows the correct output?

Exhibit

Refer to the exhibit.

```python
a = 10
b = 3
print(a / b)
print(a // b)
print(a % b)
```
Question 77hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. What is the printed value?

Exhibit

Refer to the exhibit.

```python
x = 5
y = 2
z = x ** y + x % y * 2
print(z)
```
Question 78easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes code to compute the average of two numbers entered by the user: x = input('Enter first number: '); y = input('Enter second number: '); avg = (x + y) / 2. The program produces an error. What is the best practice to fix the code?

Question 79easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes: x = 5; y = 2.0; z = x / y; print(type(z)). What is the output?

Question 80mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program contains this code: print(1 and 2 or 3). What is the output?

Question 81hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer runs the following code: x = 0.1; y = 0.2; print(x + y == 0.3). What is the output and why?

Question 82easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer wants to store a person's age. Which of these variable names is invalid?

Question 83mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes: num = input('Enter a number: '); result = num * 2; print(result). If the user enters 5, what is the output?

Question 84hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to check if a variable x is between 10 and 20 (inclusive). Which expression is correct?

Question 85easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of: print(10 // 3, 10 % 3)?

Question 86mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer accidentally wrote: print('Hello' + 5). What happens?

Question 87mediummulti select
Study the full Python automation breakdown →

Which TWO of the following Python data types are mutable?

Question 88hardmulti select
Study the full Python automation breakdown →

Which THREE of the following are valid Python variable names?

Question 89easymulti select
Study the full Python automation breakdown →

Which THREE of the following are Python data types?

Question 90mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output when the code is executed?

Exhibit

Refer to the exhibit.

def divide(a, b):
    try:
        result = a / b
        print('Result:', result)
    except ZeroDivisionError:
        print('Cannot divide by zero')
    except TypeError:
        print('Unsupported operand')

divide(10, 0)
Question 91easymultiple choice
Study the full Python automation breakdown →

What is the output from the interactive Python session?

Exhibit

Refer to the exhibit.

>>> x = 10
>>> y = 3
>>> print(x // y, x % y)
Question 92easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes a script to calculate the average of three numbers: avg = (a + b + c) / 3. If a=5, b=10, c=15, what is the data type of avg?

Question 93easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program prompts a user for their age using input(). Which line of code correctly stores the age as an integer?

Question 94easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which of the following expressions evaluates to False?

Question 95mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes: total = 2 ** 3 + 4. What is the value of total?

Question 96mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of print(10 // 3, 10 % 3)?

Question 97mediummultiple choice
Study the full Python automation breakdown →

Which of the following is a valid Python variable name?

Question 98hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer wrote: x = 10; y = 5; x += y * 2. What are the values of x and y after execution?

Question 99hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of print(type(3 + 4.5))?

Question 100hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program checks divisibility. Which condition correctly determines if a number n is divisible by 7?

Question 101easymulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following expressions produce the integer 5?

Question 102mediummulti select
Study the full Python automation breakdown →

Which TWO of the following are valid Python variable names?

Question 103hardmulti select
Study the full Python automation breakdown →

Which THREE of the following are arithmetic operators in Python?

Question 104mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer sees the above error. Which line of code likely caused it?

Exhibit

Refer to the exhibit.
Error output:
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    result = value + 10
TypeError: can only concatenate str (not "int") to str
Question 105hardmultiple choice
Study the full Python automation breakdown →

A Python program loads this JSON and accesses the first rule's action. Which expression gives the string "permit"?

Exhibit

Refer to the exhibit.
JSON policy file:
{
  "name": "access-policy",
  "rules": [
    {"action": "permit", "src": "10.0.0.0/24", "dst": "0.0.0.0/0", "protocol": "tcp"},
    {"action": "deny", "src": "0.0.0.0/0", "dst": "10.0.0.0/24", "protocol": "tcp"}
  ]
}
Question 106easymultiple choice
Study the full Python automation breakdown →

Based on the exhibit, which expression returns 2.5 in Python?

Exhibit

Refer to the exhibit.
Command output:
>>> 5 // 2
2
>>> 5 % 2
1
>>> 5 / 2
2.5
Question 107easymultiple choice
Study the full Python automation breakdown →

Which of the following is a valid Python variable name?

Question 108easymultiple choice
Study the full Python automation breakdown →

Which operator performs integer (floor) division in Python?

Question 109easymultiple choice
Study the full Python automation breakdown →

Which of the following is a valid floating-point literal in Python?

Question 110mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the following code?

print(3 * 'ab' + 'c')
Question 111mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program needs to read a user's age and print a message if they are 18 or older. Which code snippet correctly accomplishes this?

Question 112mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the data type of the expression (3.14 > 2) and ('a' < 'b')?

Question 113hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given x = 5, which of the following assignments will cause a runtime error?

Question 114hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A function sometimes returns None. Which expression correctly checks if the return value is not None?

Question 115hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which of the following expressions will evaluate to True?

Question 116easymulti select
Study the full Python automation breakdown →

Which TWO of the following are Python membership operators?

Question 117mediummulti select
Study the full Python automation breakdown →

Which THREE of the following are immutable data types in Python?

Question 118hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following expressions will evaluate to True?

Question 119mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. If the user enters 5 and 3, what is the output?

Exhibit

x = input("Enter x: ")
y = input("Enter y: ")
print(x + y)
Question 120hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. What will happen when this code is executed?

Exhibit

num = "10.5"
result = int(num)
print(result)
Question 121easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Refer to the exhibit. What is the output?

Exhibit

a = 10 // 3
b = 10 % 3
print(a, b)
Question 122easymultiple choice
Study the full Python automation breakdown →

A student writes the following code to calculate the average of two numbers: ```python num1 = input("Enter first number: ") num2 = input("Enter second number: ") avg = (num1 + num2) / 2

print("Average:", avg)

``` When executed, the code raises a TypeError. What is the most likely cause?

Question 123mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to swap the values of two variables a and b in a single line of code. Which statement correctly accomplishes this?

Question 124hardmultiple choice
Study the full Python automation breakdown →

What is the output of the following code? ```python x = 10 y = 3

print(x // y * y + x % y)

```

Question 125easymultiple choice
Study the full Python automation breakdown →

What is the output of the following code? ```python

print('Hello', 'World', sep='-')

```

Question 126mediummultiple choice
Study the full Python automation breakdown →

Which data type is most appropriate to store a user's age in a Python program?

Question 127hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A function is designed to return False if a number is not divisible by 2. Which of the following return statements correctly implements this logic?

Question 128easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the type of the result of the expression 5 + 3.0?

Question 129mediummultiple choice
Study the full Python automation breakdown →

Given the code: ```python name = input('Enter your name: ')

print('Hello, ' + name)

``` If the user enters 'Alice', what is the output?

Question 130hardmultiple choice
Study the full Python automation breakdown →

What is the output of the following code? ```python a = 'abc' b = a b = b + 'd'

print(a)

```

Question 131mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the code?

Exhibit

Refer to the exhibit.
x = 7
y = 2
result = x / y
print(type(result))
Question 132easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output when the user enters 25?

Exhibit

Refer to the exhibit.
Code:
age = input('Enter your age: ')
print(age * 2)
Input:
Enter your age: 25
Question 133mediummulti select
Study the full Python automation breakdown →

Which TWO of the following are valid Python variable names?

Question 134hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which THREE of the following expressions evaluate to True?

Question 135easymulti select
Study the full Python automation breakdown →

Which TWO data types are immutable in Python?

Question 136easymultiple choice
Read the full NAT/PAT explanation →

A junior developer writes: result = input("Enter first: ") + input("Enter second: ") and then prints result. When entering 5 and 3, the output is '53'. Which explanation is correct?

Question 137easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A programmer writes: x = 5; y = "10"; z = x + y. What will happen?

Question 138mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A company needs to process user input that must be a whole number between 1 and 100. Which code snippet correctly validates and converts the input?

Question 139hardmultiple choice
Study the full Python automation breakdown →

Which of the following is an invalid variable name in Python?

Question 140mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes the following code: a = 3; b = 2; c = a / b; d = a // b; e = a % b. What are the values of c, d, e?

Question 141easymultiple choice
Study the full Python automation breakdown →

What is the result of bool(0) in Python?

Question 142mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Evaluate the expression: not (True or False) and (False or True). What is the result?

Question 143mediummultiple choice
Study the full Python automation breakdown →

Which of the following variable names is NOT valid in Python?

Question 144hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which expression evaluates to False?

Question 145hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the most appropriate fix for the error shown in the exhibit?

Exhibit

Refer to the exhibit.
Error message:
Traceback (most recent call last):
  File "script.py", line 3, in <module>
    result = "The answer is " + 42
TypeError: can only concatenate str (not "int") to str
Question 146mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer runs the command and sees the output. Which statement about the data type is correct?

Exhibit

Refer to the exhibit.
Output of command: python3 -c "print(type(3.14))"
<class 'float'>
Question 147mediummultiple choice
Study the full Python automation breakdown →

A Python script reads this JSON and needs to check if port 8080 is allowed. Which expression correctly checks? Assume data is already parsed into a dictionary.

Exhibit

Refer to the exhibit.
JSON policy:
{
  "policy": "allow",
  "ports": [80, 443]
}
Question 148easymulti select
Study the full Python automation breakdown →

Which TWO of the following are valid Python data types?

Question 149mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following expressions evaluate to True?

Question 150hardmulti select
Study the full Python automation breakdown →

Which THREE of the following statements about Python operators are correct?

Question 151mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A weather station records temperature as a string '23.5'. The technician writes code to convert to Fahrenheit for a report. Which code will produce the correct Fahrenheit value without errors?

Question 152hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A network engineer uses bitwise operators to set flags for packet filtering. The variable 'flags' currently holds the integer 10 (binary 1010). To enable the second bit (value 2) and disable the fourth bit (value 8), which expression should be used?

Question 153easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer writes the following code: x = 5; y = x; x = 10. What are the values of x and y after execution?

Question 154mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the following code?

print('Hello', 'World', sep='-', end='!\n')
Question 155hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program evaluates the expression: (True or False) and not (True and False). What is the result?

Question 156easymultiple choice
Study the full Python automation breakdown →

What is the result of 17 % 5 in Python?

Question 157mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A programmer writes: result = 'Py' * 2 + 'thon'. What is the value of result?

Question 158easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A user enters '42' at an input prompt. After executing x = input(), what is the type of x?

Question 159hardmultiple choice
Study the full Python automation breakdown →

Refer to the exhibit. A beginner Python programmer executes the code and gets an error. What is the most likely cause?

Exhibit

>>> x = 10
>>> y = "20"
>>> print(x + y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Question 160mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to swap the values of two variables a and b without using a temporary variable. Which single line of code correctly performs the swap?

Question 161mediummulti select
Study the full Python automation breakdown →

Which two of the following are valid Python variable names? (Choose two.)

Question 162mediummulti select
Study the full Python automation breakdown →

Which three of the following are Python arithmetic operators? (Choose three.)

Question 163hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which two of the following expressions return the value 5? (Choose two.)

Question 164hardmultiple choice
Study the full Python automation breakdown →

A junior developer created a Python script to calculate the average of three quiz scores entered by the user. The script reads three numbers using input(), converts them to float, calculates the sum, and divides by 3. However, when a user enters a non-numeric value like 'ten', the script crashes with a ValueError. The developer needs to modify the script to handle such errors gracefully, allowing the user to re-enter the invalid input until a valid number is provided. Which approach should the developer implement to meet this requirement most effectively while following Python best practices?

Question 165hardmultiple choice
Study the full Python automation breakdown →

A system administrator wrote a Python script to monitor disk usage. The script reads the output of a system command that returns a string like 'Used: 45%' and extracts the percentage. The code uses slicing to get the numeric part and converts to int. However, on some servers, the output format changes to 'Used: 45.2%', causing a ValueError when converting to int. The administrator needs a robust solution that works with both integer and floating-point percentages while still producing an integer result (e.g., 45 for 45.2%). Which option is the best approach?

Question 166easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A beginner writes: x = 10; y = "20"; print(x + y). What will happen?

Question 167mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program calculates BMI. User inputs weight and height as strings. Which line correctly converts to float?

Question 168hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

After executing: a = 5; b = 2; c = a // b; d = a % b; e = a ** b. What is the value of (c + d) * 2 - e?

Question 169easymultiple choice
Study the full Python automation breakdown →

Which of the following is NOT a valid variable name in Python?

Question 170mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer needs to read an integer from user input and store it. Which code snippet accomplishes this?

Question 171hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

What is the output of the following code? print(type(3.0) == float)

Question 172easymultiple choice
Study the full Python automation breakdown →

Which operator is used for integer division in Python?

Question 173mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program prints a greeting: name = input("Enter name: "); print("Hello, " + name + "!"). If user enters "Alice", what is output?

Question 174hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Consider: x = True; y = False; z = x and not y or x. What is the value of z?

Question 175easymulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following are valid ways to determine if a variable 'x' is an integer? (Select two.)

Question 176mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which THREE of the following expressions evaluate to the integer 1? (Select three.)

Question 177hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which TWO of the following expressions evaluate to 0? (Select two.)

Question 178hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A company runs a script that processes user input temperatures. The script expects integers but sometimes users enter floats. The current code is: temp = int(input("Enter temperature: ")). When a user enters "36.5", the script crashes with a ValueError. The developer needs to modify the script to handle both integer and float inputs gracefully, converting the input to an integer (by truncation) for processing. Which of the following is the best course of action?

Question 179mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer is writing a program to calculate the average of three test scores. The current code reads scores as integers: a=int(input()); b=int(input()); c=int(input()); avg = (a+b+c)/3; print(avg). For scores 7, 8, and 9, the output is 8.0, but the requirement is to print the integer average (8), rounded to the nearest whole number. Which modification should the developer make to meet the requirement?

Question 180easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A program asks for the user's age and then prints a message: age = input("How old are you? "); print("You are " + age + " years old."). A user enters "twenty five" and the program prints "You are twenty five years old." which is not the intended numeric age. The requirement is to ensure only numeric ages are accepted and to convert the input to an integer. Which modification is the best?

Question 181mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A company needs to calculate the average of three test scores entered by a user. The scores are integers. The programmer writes the following code:

s1 = input("Enter score 1: ") s2 = input("Enter score 2: ") s3 = input("Enter score 3: ") avg = (s1 + s2 + s3) / 3

print("Average:", avg)

When run, the output is incorrect. What is the most likely cause?

Question 182easymulti select
Study the full Python automation breakdown →

Which of the following are valid Python variable names? (Choose two.)

Question 183mediummulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Which of the following expressions evaluate to True? (Choose three.)

Question 184hardmulti select
Read the full Data Types, Variables, Basic I/O and Operators explanation →

Given the following code, which of the following statements are true after execution? (Choose three.)

x = 10 y = 3.0 z = x / y w = x // y

Question 185easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A junior developer is writing a script to calculate the total cost of items in a shopping cart. The script uses variables item_price (float) and quantity (int). The code is:

item_price = 2.5 quantity = 3 total = item_price * quantity

print("Total: " + total)

When run, this code raises a TypeError. The developer is confused because the multiplication seems correct. What is the most likely issue and the correct fix?

Question 186easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A data analyst needs to read two integers from the user and compute their average as a float. The current code:

a = int(input()) b = int(input()) avg = a + b / 2

print(avg)

The output is always incorrect when a=5 and b=7 (expected 6.0, actual 8.5). The analyst cannot identify the bug. What is the root cause and correct fix?

Question 187mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A system administrator writes a script to monitor disk usage. The script reads a percentage from a file as a string, e.g., "100". The code:

usage = open("usage.txt").read().strip()

if usage > 80:
    print("Warning: disk usage high")

else:

print("Disk usage OK")

Even when usage.txt contains "100", the script prints "Disk usage OK". The admin expected "Warning". What is the problem and how to fix?

Question 188mediummultiple choice
Study the full Python automation breakdown →

A student is learning Python and writes a program to compute the area of a rectangle. The code:

length = input("Enter length: ") width = input("Enter width: ") area = length * width

print("Area:", area)

When the user enters 5 and 3, the program crashes with a TypeError: can't multiply sequence by non-int of type 'str'. The student is puzzled because they thought input returns numbers. What is the correct explanation and fix?

Question 189hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer is building a simple calculator that accepts two numbers and an operator string. The code:

x = float(input("First: ")) y = float(input("Second: ")) op = input("Operator (+, -, *, /): ")

if op == "+":

result = x + y elif op == "-": result = x - y elif op == "*": result = x * y elif op == "/": result = x / y

print("Result:", result)

When the user enters 10, 3, and "/", the output is "Result: 3.3333333333333335". The developer wants to display only two decimal places. Which code change will achieve this without introducing errors?

Question 190easymultiple choice
Study the full Python automation breakdown →

A beginner Python learner writes a script to swap two numbers:

a = 10 b = 20 a = b b = a

print("a =", a, "b =", b)

The output is "a = 20 b = 20". The learner expected "a = 20 b = 10". Which of the following is the most Pythonic way to fix the code?

Question 191mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A programmer is writing a script to read a number, determine if it is even or odd, and then also use the number to calculate its square. The code:

num = input("Enter a number: ")

if num % 2 == 0:
    print("Even")

else:

print("Odd")

square = num ** 2

print("Square:", square)

When run, a TypeError occurs on the modulo line. Which fix will resolve the error and allow the later calculation to work?

Question 192hardmultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A developer is working on a project that requires handling large numbers. They write:

x = 10000000000 y = 3.0 z = x / y

print(int(z))

The output is 3333333333. However, the developer expected 3333333333 (same). But they suspect that integer division might be better. They try:

x = 10000000000 y = 3 z = x // y

print(z)

Output: 3333333333. Both give same. Now they test with negative numbers:

x = -10 y = 3 z1 = x / y z2 = x // y

print(z1, z2)

The output is -3.3333333333333335 and -4. The developer is confused why z2 is -4 instead of -3. Which of the following explains the behavior?

Question 193mediummultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A data scientist needs to read a list of floats from a file, one per line, and compute the sum. The current code:

total = 0.0

with open("data.txt") as f:
    for line in f:

total = total + line

print(total)

When run, a TypeError occurs: unsupported operand type(s) for +: 'float' and 'str'. The scientist knows that line is a string. Which fix will correctly sum the numbers?

Question 194easymultiple choice
Read the full Data Types, Variables, Basic I/O and Operators explanation →

A student tries to write a program that prints the square of a number. The code:

num = 5

print("The square is " + num ** 2)

When run, a TypeError occurs. Which of the following fixes the error and produces exactly the output 'The square is 25'?

Practice tests

Scored 10-question sessions with instant feedback and explanations.

PCEP Practice Test 1 — 10 Questions→PCEP Practice Test 2 — 10 Questions→PCEP Practice Test 3 — 10 Questions→PCEP Practice Test 4 — 10 Questions→PCEP Practice Test 5 — 10 Questions→PCEP Practice Exam 1 — 20 Questions→PCEP Practice Exam 2 — 20 Questions→PCEP Practice Exam 3 — 20 Questions→PCEP Practice Exam 4 — 20 Questions→Free PCEP Practice Test 1 — 30 Questions→Free PCEP Practice Test 2 — 30 Questions→Free PCEP Practice Test 3 — 30 Questions→PCEP Practice Questions 1 — 50 Questions→PCEP Practice Questions 2 — 50 Questions→PCEP Exam Simulation 1 — 100 Questions→

Practice by domain

Each domain maps to a weighted exam section. Focus on the domain where you are weakest.

Computer Programming and Python FundamentalsData Types, Variables, Basic I/O and OperatorsControl Flow, Loops, Lists and LogicFunctions, Tuples, Dictionaries and Exceptions

Practice by scenario

Filter questions by type — troubleshooting, exhibit, drag-and-drop, PBQ, ACLs, OSPF, and more.

Browse scenarios→

Continue studying

All Data Types, Variables, Basic I/O and Operators setsAll Data Types, Variables, Basic I/O and Operators questionsPCEP Practice Hub