logo

Crowdly

Browser

Add to Chrome

COSC121-25S1 - Introduction to Computer Programming

Looking for COSC121-25S1 - Introduction to Computer Programming test answers and solutions? Browse our comprehensive collection of verified answers for COSC121-25S1 - Introduction to Computer Programming at learn.canterbury.ac.nz.

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

What is the output from the following program?

f1 = 10.0 ** 20

f2 = f1 + 1.0

if f1 != f2:

print("Yay my high school arithmetic works")

else:

print("Oh no! What went wrong?")

a = 3.0 * 0.1 / 3

if a == 0.1:

print("I should think so too")

else:

print("Huh?")

1f1 = 10.0 ** 20f2 = f1 + 1.0if f1 != f2: print("Yay my high school arithmetic works")else: print("Oh no! What went wrong?")a = 3.0 * 0.1 / 3if a == 0.1: print("I should think so too")else: print("Huh?")  ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXHint: Try the arithmetic expressions yourself in the Python Shell.
0%
0%
0%
0%
0%
View this question

The previous question showed that Python sometimes produces apparently wrong answers. What was the cause of the problem in that case?

0%
0%
0%
0%
View this question

What is the output from the following program?

f1 = 10.0 ** 20

f2 = f1 + 1.0

if f1 != f2:

print("Yay my high school arithmetic works")

else:

print("Oh no! What went wrong?")

a = 3.0 * 0.1 / 3

if a == 0.1:

print("I should think so too")

else:

print("Huh?")

Hint: Try the arithmetic expressions yourself in the Python Shell.
0%
0%
0%
0%
View this question

Why does the following program result in an error?

def check_age(age):

"""A docstring that gives nothing away"""

if age < 18:

underage = True

elif age > 18:

underage = False

return underage

print(check_age(18))

View this question

In the following code (representing an attempt to bribe a tramper), what would you have to change so that the function go_on_tramp gets called, regardless of the value of payment? You may assume that both payment (an assigned integer) and the function go_on_tramp are defined elsewhere.

if payment >= 50:

payment_is_sufficient = True

else:

payment_is_sufficient = False

if payment_is_sufficient and (not payment_is_sufficient):

go_on_tramp()

View this question

Given the following code for determining if a person has paid enough to go on a tramp:

if payment >= 50:

payment_is_sufficient = True

else:

payment_is_sufficient = False

if payment_is_sufficient and (not payment_is_sufficient):

go_on_tramp()

Which of the following payments will ensure that the function go_on_tramp, assumed to be defined elsewhere, gets called?

0%
0%
0%
0%
View this question

What does the following code print?

number = 45

if number >= 70:

print("Luke, I am your father")

elif number >= 45:

print("I'll be Bach")

elif number > 15:

print("...Bond. James Bond.")

else:

print("Go ahead, make my day")

View this question

Why does the following program result in an error?

def check_age(age):

"""A docstring that gives nothing away"""

if age < 18:

underage = True

elif age > 18:

underage = False

return underage

print(check_age(18))

1def check_age(age): """A docstring that gives nothing away""" if age < 18: underage = True elif age > 18: underage = False return underageprint(check_age(18))  ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0%
0%
0%
0%
0%
0%
View this question

In the following code (representing an attempt to bribe a tramper), what would you have to change so that the function go_on_tramp gets called, regardless of the value of payment? You may assume that both payment (an assigned integer) and the function go_on_tramp are defined elsewhere.

if payment >= 50:

payment_is_sufficient = True

else:

payment_is_sufficient = False

if payment_is_sufficient and (not payment_is_sufficient):

go_on_tramp()

123456if payment >= 50: payment_is_sufficient = Trueelse: payment_is_sufficient = Falseif payment_is_sufficient and (not payment_is_sufficient): go_on_tramp()  ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0%
0%
0%
100%
0%
View this question

Given the following code for determining if a person has paid enough to go on a tramp:

if payment >= 50:

payment_is_sufficient = True

else:

payment_is_sufficient = False

if payment_is_sufficient and (not payment_is_sufficient):

go_on_tramp()

1if payment >= 50: payment_is_sufficient = Trueelse: payment_is_sufficient = Falseif payment_is_sufficient and (not payment_is_sufficient): go_on_tramp()  ההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Which of the following payments will ensure that the function go_on_tramp, assumed to be defined elsewhere, gets called?

0%
0%
0%
0%
View this question

Want instant access to all verified answers on learn.canterbury.ac.nz?

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

Browser

Add to Chrome