Pre-Summer Sale Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: mxmas70

Home > WGU > Courses and Certificates > Foundations-of-Programming-Python

Foundations-of-Programming-Python Foundations of Programming (Python) - E010 JIV1 Question and Answers

Question # 4

Complete the function double_number(num) that takes one number parameter and returns double that number.

For example, double_number(5) should return 10.

def double_number(num):

# TODO: Return double the input number

# Example: double_number(5) should return 10

pass

Full Access
Question # 5

What distinguishes a terminal-based Python environment from other development environments?

A.

Graphical user interface elements

B.

Required internet connectivity for operation

C.

Text-based command line interface

D.

Automatic file saving capabilities

Full Access
Question # 6

Complete the function format_name(first, last) that takes a first name and last name and returns them combined as " last, first " .

For example, format_name( " John " , " Smith " ) should return " Smith, John " .

def format_name(first, last):

# TODO: Return the name in " last, first " format

pass

Full Access
Question # 7

Which components are required in every Python while loop?

A.

A condition and an indented code block

B.

A variable and a return statement

C.

A counter and a break statement

D.

An iterator and a list

Full Access
Question # 8

Complete the function calculate_tip(bill, tip_percent) that calculates and returns the tip amount based on the bill and tip percentage.

For example, calculate_tip(50, 20) should return 10.0.

def calculate_tip(bill, tip_percent):

# TODO: Calculate and return the tip amount

pass

Full Access
Question # 9

Which action allows a Python script located in a different folder to be executed in the terminal?

A.

Use the edit command to open the script first

B.

Move the script to your desktop

C.

Use the cd command to navigate to the script ' s directory

D.

Rename the script to match the terminal ' s path

Full Access
Question # 10

Which loop structure processes every individual item in a list called grades?

A.

while len(grades) > 0:

B.

for grade in grades:

C.

for i in range(grades):

D.

while grades[0]

Full Access
Question # 11

Fix the missing function call in this function that should return the uppercase version of a string.

def make_uppercase(text):

return text.upper

Full Access
Question # 12

Which tool is used to execute Python code line-by-line interactively within a terminal?

A.

Python shell

B.

Text editor

C.

File explorer

D.

Debugger

Full Access
Question # 13

Which for loop correctly iterates through a list of student names?

A.

for name in [ ' Alice ' , ' Bob ' , ' Carol ' ]:

B.

for name with [ ' Alice ' , ' Bob ' , ' Carol ' ]:

C.

for name from [ ' Alice ' , ' Bob ' , ' Carol ' ]:

D.

for name = [ ' Alice ' , ' Bob ' , ' Carol ' ]

Full Access
Question # 14

What does the string method ' ' .join() return when applied to the list [ ' Hello ' , ' World ' ]?

A.

' Hello,World '

B.

' HelloWorld '

C.

' Hello World '

D.

' Hello, World '

Full Access
Question # 15

Write a complete function reverse_string(text) that takes a string and returns it reversed.

For example, reverse_string( " hello " ) should return " olleh " .

def reverse_string(text):

# TODO: Return the reversed string

pass

Full Access
Question # 16

Which type of loop is designed for iterating a specific number of times?

A.

while loop

B.

for loop

C.

Infinite loop

D.

do-while loop

Full Access
Question # 17

Which Python data structure automatically prevents duplicate values from being stored?

A.

List

B.

Tuple

C.

Dictionary

D.

Set

Full Access
Question # 18

A program uses this while loop to count down:

count = 5

while count > 0:

print(count)

Which issue is preventing the loop from working correctly?

A.

There is a missing colon after the condition.

B.

It runs infinitely because count is never modified.

C.

The condition should use > = instead of > .

D.

The variable should be named differently.

Full Access