Python Lesson 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following about Python namespace is true?

A. A namespace is a container that provides a named context for a set of identifiers B. Namespaces enable programs to avoid potential name clashes by associating each identifier with the namespace from which it originates C. Each Python module has its own namespace D. All of the above (yup)

Students in a course get a P grade if they score 60 or above in the final exam and F grade if they score less than 60. Which of the following functions correctly returns the grade?

A. def grade_converter(score): if score >= 60: grade = 'P' else: grade = 'F' return grade B. def grade_converter(score): if score >= 60: return 'P' else: return 'F' C. Both (A) and (B) (yup)

def get_course(): course_code = input("Enter course code: ") section_num = input("Enter section number: ") return course_code, section_num

course_code, section_num = get_course()

Which of the following functions displays the GPA entered by the user and also sends it to the calling function?

def get_gpa(): gpa = float(input("Enter GPA: ")) print(gpa) return gpa

Which of the following functions sends the the GPA entered by the user to the calling function?

def get_gpa(): gpa = float(input("Enter GPA: ")) return gpa

In a fitness test the heart rates before and after a 10-minute exercise are measured. Which of the following functions correctly return both heart rates?

def get_heart_rates(): hrb = int(input("Enter heart rate before exercise: ")) hra = int(input("Enter heart rate after exercise: ")) return hrb, hra

Suppose get_gpa is a value returning function that returns the GPA entered by the user. Which of the following main functions will display the gpa successfully?

def main(): gpa = get_gpa() print(gpa)

Suppose there are four functions in the circle modules. Which of the following statements imports only the circumference function?

from circle import circumfernce

import math x = float(input("Enter a number: ")) square_root = math.sqrt(x) print("The square root of the number is", square_root) The name math.sqrt includes both the namespace and the function name. It is a ________

fully qualified name

Suppose we have used the import math statement to import the math module. Which of the following statements correctly calls the sqrt function of the math module to calculate the square root of x?

square_root = math.sqrt(x)


Kaugnay na mga set ng pag-aaral

Risk Management: Emergency and Spill Response

View Set

MGMT 371 Iowa State: Quiz 3 Ch 7,8

View Set

Saunder's Comprehensive Review Ethical and Legal Issues

View Set

FW 343 Application Activity Part 1

View Set

Chapter 15: Limited Liability Companies, Limited Liability Partnerships, and Special Forms of Business

View Set