1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
WARRIOR [948]
3 years ago
13

Write the definition of a class WeatherForecast that provides the following behavior (methods): A method called set_skies that h

as one parameter, a String. A method called set_high that has one parameter, an int. A method called set_low that has one parameter, an int. A method called get_skies that has no parameters and that returns the value that was last used as an argument in set_skies. A method called get_high that has no parameters and that returns the value that was last used as an argument in set_high. A method called get_low that has no parameters and that returns the value that was last used as an argument in set_low. No constructor need be defined. Be sure to define instance variables as needed by your "get"/"set" methods.
Computers and Technology
1 answer:
Ann [662]3 years ago
5 0

Answer:

class WeatherForecast(object):

 

skies = ""

min = 0

max = 0

 

def get_skies(self):

return self.skies

def set_skies(self, value):

self.skies = value

def get_max(self):

return self.max

 

def set_max(self, value):

self.max = value

 

def get_min(self):

return self.min

def set_min(self, value):

self.min = value

def main():

obj1 = WeatherForecast()

obj1.set_skies("Skies1")

obj1.set_max(2)

obj1.set_min(0)

print("Calling get_skies(): ", obj1.get_skies())

print("Calling get_max(): ", obj1.get_max())

print("Calling get_min(): ", obj1.get_min())

main()

Explanation:

  • Inside the WeatherForecast class, initialize variables for skies, minimum and maximum.
  • Define the getter and setter method for the necessary variables inside the WeatherForecast class.
  • Create an object of the class WeatherForecast.
  • Call the getter functions of  the class and display the results.
  • Finally call the main function to test the program.
You might be interested in
In order for the image tag in an HTML file to function properly, the file named square.png must be located where?
andrey2020 [161]
A is wrong because a folder can have any name.
B is wrong because not all folders of a web server are exposed to the outside, only all folders below the document root.
C sounds good
D is wrong because an image can reside somewhere else as long as you specify the absolute or relative path to it
7 0
3 years ago
Read 2 more answers
Write a program that prompts the user to enter an equation in the form of 10 5, or 10-5, or 1*5, or 13/4, or 13%4. The program s
grandymaker [24]

Answer:

  1. equation = input("Enter an equation: ")
  2. if("+" in equation):
  3.    operands = equation.split("+")
  4.    result = int(operands [0]) + int(operands[1])
  5.    print(operands[0] + "+" + operands[1] + "=" + str(result))
  6. elif("-" in equation):
  7.    operands = equation.split("-")
  8.    result= int(operands [0]) - int(operands[1])
  9.    print(operands[0] + "-" + operands[1] + "=" + str(result))  
  10. elif("*" in equation):
  11.    operands = equation.split("*")
  12.    result = int(operands [0]) * int(operands[1])
  13.    print(operands[0] + "*" + operands[1] + "=" + str(result))  
  14. elif("/" in equation):
  15.    operands = equation.split("/")
  16.    result = int(operands [0]) / int(operands[1])
  17.    print(operands[0] + "/" + operands[1] + "=" + str(result))  
  18. elif("%" in equation):
  19.    operands = equation.split("%")
  20.    result = int(operands [0]) % int(operands[1])
  21.    print(operands[0] + "%" + operands[1] + "=" + str(result))

Explanation:

The solution code is written in Python 3.

Firstly prompt user to enter an equation using input function (Line 1).

Create if-else if statements to check if operator "+", "-", "*", "/" and "%" exist in the input equation. If "+" is found (Line 3), use split method to get the individual operands from the equation by using "+" as separator (Line 5). Output the equation as required by the question using string concatenation method (Line 6).  The similar process is repeated for the rest of else if blocks (Line 7 - 22).  

5 0
3 years ago
The find_item functions uses binary search to recursively locate an item is the list, returning true if found, false otherwise.
bagirrra123 [75]

Answer:

def find_item(listed, item):

   listed.sort()

   #Returns True if the item is in the list, False if not.

   if len(listed) == 0:

       return False

   middle = int(len(listed)/2)

   #Is the item in the first half of the list?

   if item < listed[middle]:

   #Call the function with the first half of the list

       return find_item(listed[:middle], item)

   

   #Is the item in the center of the list?

   if listed[middle] == item:

       return True

   else:

   #Call the function with the second half of the list

       return find_item(listed[middle+1:], item)

   return False

list_of_names = ["Parker", "Drew", "Cameron", "Logan", "Alex", "Chris", "Terry", "Jamie", "Jordan", "Taylor"]

print(find_item(list_of_names, "Alex")) # True

print(find_item(list_of_names, "Andrew")) # False

print(find_item(list_of_names, "Drew")) # True

print(find_item(list_of_names, "Jared")) # False

Explanation:

The defined python function is used to implement a binary search, the function is recursively called in the function statement, but for it to work on the list ( ie, search for an item in the list), the list must be sorted in ascending order (default).

7 0
3 years ago
Complete the sentence to identify advantages of top-down programming design. Choose all that apply.
yanalaym [24]

Answer:The original choice to write apply_fg so that it accepts function arguments is a good one, because it increases interoperability. When the callable arguments to apply_fg use a single protocol, we can easily exchange them: #include <functional> float log2(float); int a = apply_fg(5.Of, int b = apply_fg(3.14f,

Explanation:

3 0
3 years ago
Read 2 more answers
Marty uses a customized database to sort parts and track inventory. The customized database is an example of _____.
Alexeev081 [22]

cataloging is a term for that

5 0
3 years ago
Other questions:
  • When looking at an object or process to code, it is important to think of as general a solution as possible and consider all the
    13·1 answer
  • It is important to ____ the line in the code editing window in the exact location where you want to insert a code snippet to pro
    10·1 answer
  • .<br> 1. Press the _______ key to move to the next cell in a row.
    14·2 answers
  • Using the __________ option, you can change the state of a model back to where a particular feature or features weren`t yet crea
    7·1 answer
  • What is the subnet mask ?
    9·2 answers
  • Ancestor(X,father(X)) and ancestor(david,george) is they unify or not
    11·1 answer
  • What do you think is the most fascinating aspect of the internet?
    7·2 answers
  • GIVING BRAINLIEST Jenna creates advertisements for companies to air on television. Which file format will best preserve the grap
    5·2 answers
  • What is problem scoping
    14·1 answer
  • Plsssssssss help me​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!