logo

Crowdly

Programming Fundamentals-Lecture,Section-1-Fall 2024

Looking for Programming Fundamentals-Lecture,Section-1-Fall 2024 test answers and solutions? Browse our comprehensive collection of verified answers for Programming Fundamentals-Lecture,Section-1-Fall 2024 at moodle.nu.edu.kz.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Given the following function definition, choose function calls that are valid and will not raise an error.

def multiply_all(*args):

result = 1

for num in args:

result *= num

return result

View this question

Given the following program, what will be printed if the user enters 6 and 0?

while True:

try:

a = int(input("Enter a number: "))

b = int(input("Enter a number: "))

c = a/b

except ZeroDivisionError:

print("b cannot be 0")

except ValueError:

print("Enter a number")

else:

print("result is ", c)

finally:

print("testing...")

View this question

What is printed when the following code is executed?

counter = 0

def update_counter():

global counter

counter += 1

def reset_counter():

global counter

counter = 0

update_counter()

update_counter()

reset_counter()

update_counter()

print(counter)

View this question

Suppose you have a custom Python module called custom_math.py with the following functions, then choose all correct imports and uses of functions from this module.

# custom_math.py

def add(a, b):

return a + b

def subtract(a, b):

return a - b

def multiply(a, b):

return a * b

def divide(a, b):

if b == 0:

return "Division by zero error"

return a / b

View this question

Given the following program, what will be printed if the user enters 6 and 6?

while True:

try:

a = int(input("Enter a number: "))

b = int(input("Enter a number: "))

c = a/b

except ZeroDivisionError:

print("b cannot be 0")

except ValueError:

print("Enter a number")

else:

print("result is ", c)

finally:

print("testing...")

View this question

Consider the following Python function definition:

def calculate_price(amount, tax=0.05, discount=0.10):

return amount + (amount * tax) - (amount * discount)

Which of the following function calls will produce the same result as calculate_price(100, 0.1)?

0%
View this question

Given the global variable counter and followed by function calls with their expected behavior, choose all correct definitions of update_value() and reset_counter() functions

counter = 0

update_counter(5) # counter becomes 5

update_counter(3) # counter becomes 8

reset_counter() # counter becomes 0

update_counter(2) # counter becomes 2

print(counter) # Output: 2

View this question

Given the function definition below, choose function calls that are valid and will not raise an error.

def display_info(**kwargs):

for key, value in kwargs.items():

print(f"{key}: {value}")

View this question

print(s4)

View this question

print(s1+s2)

View this question

Want instant access to all verified answers on moodle.nu.edu.kz?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!