Hi, this is just an ungraded review guide for my python class. I want to do well on the exam so I am just seeking help because I struggle in some areas. Thank you for your help. QUESTION 1   Given the following statement that calls an object's method, what is the name of the object? What is the name of the method?   fridge.get_food()     QUESTION 2   The following statements call a function named makeHalf, which returns a value that is half of the argument that was passed to it.  Write the code for the makeHalf function.   number = 7.75   Result = makeHalf(number)   QUESTION 3   Write nested decision structures that perform the following: If Amount1 is greater than 20 and Amount2 is less than 75, display the greater of Amoun1 and Amount2.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 3RQ
icon
Related questions
Question
Hi, this is just an ungraded review guide for my python class. I want to do well on the exam so I am just seeking help because I struggle in some areas. Thank you for your help.

QUESTION 1
 
Given the following statement that calls an object's method, what is the name of the object? What is the name of the method?
 
fridge.get_food()
 
 
QUESTION 2
 
The following statements call a function named makeHalf, which returns a value that is half of the argument that was passed to it.  Write the code for the makeHalf function.
 
number = 7.75
 
Result = makeHalf(number)
 
QUESTION 3
 
Write nested decision structures that perform the following: If Amount1 is greater than 20 and Amount2 is less than 75, display the greater of Amoun1 and Amount2.
 
QUESTION 4
 
Write a function that accepts a list as an argument (assume the list contains integers) and returns the total of the values in the list.
 
QUESTION 5
 
Write the first line of the definition for a Laborador class that will extend the Dog class.
 
QUESTION 6
 
Write an if statement that assigns 100 to the variable apple then assigns 50 to the variable carrot if the variable apple is greater than 100.
 
QUESTION 7
 
Write a Python statement that creates a Label widget. Its parent should be self.main_ window and its text should be 'Happy New Year!'.
 
QUESTION 8
 
What will the following code display?
 
shortstring = 'the fox jumped over the log'
 
print(shortstring[3:6]
 
QUESTION 9
 
Write a while loop that lets the user enter a number. The number should be mulutiplied by 10, and the result assigned to a variable named Product. The loop should repeat as long as Product is less than 100.
 
QUESTION 10
 
What will the following code display on the screen?
 
def main():
 
x = 3
 
y = 5.5
 
print(x, y)
 
change_it(x, y)
 
print(x, y)
 
def chang_it(a, b):
 
a = 1
 
b = 1
 
print(a, b)
 
main()
 
QUESTION 11
 
Write Python code that does the following: opens an output file with the file name numberList.txt, then uses a loop to write the numbers 1 through 50 to the file, then closes the file.
 
QUESTION 12
 
What string method would you use to return a copy of a string with all leading and trailing whitespaces removed?
 
QUESTION 13
 
Describe the difference between a list and a tuple. Provide an example of when you might use each, and explain why.
 
QUESTION 14
 
Write a class definition named Article. The Article class should have data attributes for the article's title, the author's name, and the publisher's name. The class should also have the following:
 
An __init__ method for the class which will accept an argument for each of the data attributes.
Accessor and mutator methods for each data attribute
An __str__ method that returns a string indicating the state of the object.
 
QUESTION 15
 
Write a set of nested loops that display 10 rows of % characters. There should be 10 % characters displayed in each row.
 
QUESTION 16
 
Write Python code that prompts the user to enter their favorite color and assigns the user's input to the variable named FavColor.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning