Python for IT Automation - D522 PA multiple choice

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

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:59 PM on 5/19/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

39 Terms

1
New cards

Which function should be used to add data to a file, such as a network configuration file?

write()

3 multiple choice options

2
New cards

Based on the Python code snippet:

def greet(name, greeting = "Welcome to WGU"):

return f"{greeting}, {name}!"

What is the purpose of the first line of code?

To define a function with a default greeting

3 multiple choice options

3
New cards

This Python code snippet returns a syntax error when run:

def multiply_numbers(num1, num2)

result = num1 * num2

return result

num1 = 5

num2 = 8

print(multiply_numbers(num1, num2))

Which code adjustment will resolve the syntax error?

Add a colon after def multiply_numbers(num1, num2).

3 multiple choice options

4
New cards

Based on the Python snippet:

devices = ["router01", "switch01", "modem01", "gateway01", "printer01"]

Which data structure is being used to store the names for various types of devices within devices?

List

3 multiple choice options

5
New cards

Based on the Python snippet:

value = input("Enter a number: ")

result = int(value) + 10

print(result)

What purpose does result = int(value) + 10 serve?

Converts the user's input into an integer and sums it

3 multiple choice options

6
New cards

A developer is creating a Python script to capture metrics for different network interfaces on a router, with each set of metrics treated as a single, immutable record. The stored record will represent a snapshot of metrics for a specific network interface at a given point in time to capture historical records for future analysis.

Which data structure should be used to store the recorded metrics based on the specifications?

Tuple

3 multiple choice options

7
New cards

Based on the Python list:

numbers = [10, 20, 30, 40]

What is the index position of the element "40"?

numbers[3]

3 multiple choice options

8
New cards

Which characteristics are associated with tuples in Python?

Ordered and unchangeable

3 multiple choice options

9
New cards

What is the error in the following Python code?

port = input(“Secure Web access? Y/N: “)

if port == “Y”

print(“Use port 443.”)

else

print(“Use port 80.”)

Missing colons at the end of if and else lines

3 multiple choice options

10
New cards

What will be the result of this Python expression?

result = 5 + 3 * 2

11

3 multiple choice options

11
New cards

What is the purpose of the is operator in Python?

To check if two variables refer to the same object in memory

3 multiple choice options

12
New cards

What is the result of this Python expression?

bool(0)

False

2 multiple choice options

13
New cards

Which method is used to return the number of elements in a list?

len()

3 multiple choice options

14
New cards

Which of the following is used to declare a function in Python?

def

3 multiple choice options

15
New cards

What is the output of the following code?

print(3 ** 2)

9

3 multiple choice options

16
New cards

How can you convert the string “123” into an integer in Python?

int("123")

3 multiple choice options

17
New cards

What is the default value of the step parameter in Python’s string slicing?

1

3 multiple choice options

18
New cards

Which of the following methods removes whitespaces from the beginning and the end of a string in Python?

strip()

3 multiple choice options

19
New cards

What will be the result of this Python code?

fruits = [‘apple’, ‘banana’, ‘cherry’]

print(fruits[-1])

cherry

3 multiple choice options

20
New cards

Which of the following creates a dictionary in Python?

{key: value}

3 multiple choice options

21
New cards

Which Python method is used to add an item to the end of a list?

append()

3 multiple choice options

22
New cards

Which operator is used to check if an element exists in a list?

in

3 multiple choice options

23
New cards

What is the output of the following code?

print(“Hello” + “World”)

HelloWorld

1 multiple choice option

24
New cards

How would you access the value associated with the key “name” in the dictionary below?

person = {“name”: “John”, “age”: 30}

person["name"]

3 multiple choice options

25
New cards

Which Python method is used to combine two lists?

extend()

3 multiple choice options

26
New cards

What is the output of this Python code?

numbers = [1, 2, 3]

numbers[0] = 10

print(numbers)

[10, 2, 3]

2 multiple choice options

27
New cards

What will this code return?

my_str = “Hello World”

print(my_str[0:5])

Hello

3 multiple choice options

28
New cards

What does this Python code output?

print(2 * 3 ** 2)

18

3 multiple choice options

29
New cards

How can you create a tuple in Python?

(1, 2, 3)

3 multiple choice options

30
New cards

Which of the following is not a valid Python data type?

array

3 multiple choice options

31
New cards

Which keyword is used to define a class in Python?

class

3 multiple choice options

32
New cards

What does the following Python expression return?

len([10, 20, 30])

3

3 multiple choice options

33
New cards

Which of the following Python keywords is used to create a loop?

for

3 multiple choice options

34
New cards

How do you remove an element from a list in Python?

remove()

3 multiple choice options

35
New cards

What does the continue statement do in Python loops?

Skips the current iteration and moves to the next

3 multiple choice options

36
New cards

What is the output of this code?

my_str = “Hello”

print(my_str[-1])

o

3 multiple choice options

37
New cards

What does this Python code return?

x = 7

y = 5

print(x % y)

2

3 multiple choice options

38
New cards

How do you declare an empty set in Python?

set()

3 multiple choice options

39
New cards

What is the output of the following Python code?

x = 5

y = 10

print(x == y)

False

3 multiple choice options

Explore top flashcards

flashcards
Mankind: the story of all of us
49
Updated 597d ago
0.0(0)
flashcards
APUSH Chapter 20
49
Updated 1130d ago
0.0(0)
flashcards
English 1h Semester two Final
149
Updated 1047d ago
0.0(0)
flashcards
Cardiovascular System
58
Updated 1140d ago
0.0(0)
flashcards
Lenses
21
Updated 29d ago
0.0(0)
flashcards
frans - vocabulaire p18-20
61
Updated 545d ago
0.0(0)
flashcards
Mankind: the story of all of us
49
Updated 597d ago
0.0(0)
flashcards
APUSH Chapter 20
49
Updated 1130d ago
0.0(0)
flashcards
English 1h Semester two Final
149
Updated 1047d ago
0.0(0)
flashcards
Cardiovascular System
58
Updated 1140d ago
0.0(0)
flashcards
Lenses
21
Updated 29d ago
0.0(0)
flashcards
frans - vocabulaire p18-20
61
Updated 545d ago
0.0(0)