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
Oksanka [162]
4 years ago
14

In this code, identify the repeated pattern and replace it with a function called month_days, that receives the name of the mont

h and the number of days in that month as parameters. Adapt the rest of the code so that the result is the same. Confirm your results by making a function call with the correct parameters for both months listed.

Computers and Technology
1 answer:
expeople1 [14]4 years ago
6 0

Answer:

Here is the function month_days:

def month_days(month, days):

 print (month +" has " + str(days) + " days.")

Now call this function by passing values to it as:

month_days ("June", 30)

month_days("July", 31)

The above function can also be written as:

def month_days(month, days):

 return (month +" has " + str(days) + " days.")

Now call this function by passing values to it and using print function to see the result on output screen:

print(month_days ("June", 30))

print(month_days("July", 31))

Explanation:

The above code has a function month_days which receives two arguments i.e. month which is the name of the month and days which is the number of days in that month. The method has a statement return (month +" has " + str(days) + " days.") which returns the name of the month stored in month variable followed by has word followed by the number of days stored in days variable which is followed by the word string days.

So if user passes "June" as month and 30 as days then the program has the following output:

June has 30 days.

The above program can also be written by using f-string to specify the format of the output in function month_days:

def month_days(month, days):

   output = f"{month} has {days} days."

   return (output)

Now call this function to see the output on the screen

print (month_days("June", 30))

print (month_days("July", 31))

The f-string is prefixed with 'f', which contains arguments month and days inside braces. These expressions i.e. month and days are replaced with their values specified in the calling statement.

Screenshot of the program and its output is attached.

You might be interested in
Which of the following would be better communicated with an image than with text?
slega [8]

Answer:

A decor to a wedding

Explanation:

its bc who would want to know how its described when u could look of how it looks u might be speechless

8 0
3 years ago
In class, we discussed static local variables in C. Answereach question below; if necessary, find and consult a reference on the
alexira [117]

Answer:

(a) scope: function, lifetime: duration of the function

(b) scope: function, lifetime: duration of the program

(c) scope: global (all modules),  lifetime: duration of the program

(d) scope: module (file), lifetime: duration of the program

6 0
3 years ago
4) Which is a more efficient way to determine the optimal number of multiplications in a matrix-chain multiplication problem: en
Assoli18 [71]

Answer:

Running RECURSIVE-MATRIX-CHAIN is asymptotically more efficient than enumerating all the ways of parenthesizing the product and computing the number of multiplications of each.

the running time complexity of enumerating all the ways of parenthesizing the product is n*P(n) while in case of RECURSIVE-MATRIX-CHAIN, all the internal nodes are run on all the internal nodes of the tree and it will also create overhead.

Explanation:

3 0
3 years ago
A social media site violates its terms of service by selling information about its users
balu736 [363]
A company violating its terms of service by selling their user’s info is a violation of Digital Privacy
4 0
3 years ago
In what Career Cluster you get to design, build, and destroy things
vaieri [72.5K]

Answer: Architecture

Explanation:

A career cluster can be defined as the group of careers in which professionals are related to common features or occupational tasks are related based on the common features. One person in a career cluster may like more than one job profiles in the same career cluster.

In architecture a person may like to design, build and destroy things to redesign them again. This involves knowledge, skills, mental and physical labor. Building and road constructions are the tasks performed by the architectures.

7 0
3 years ago
Other questions:
  • A(n) ____________________ or cryptosystem is an encryption method or process encompassing the algorithm, key(s) or cryptovariabl
    11·1 answer
  • What is the protocol in the web search at the bottom?
    13·1 answer
  • An item such as a smart card is an example of the _______ form of authentication.
    10·1 answer
  • Which of the following is NOT a component of a DFD?
    8·1 answer
  • To print a range of cells in the active worksheet, click ____ in the settings area in the print gallery.
    14·1 answer
  • Project using simple formulas
    15·1 answer
  • Which small-group format would be most appropriate for the following situation? A large sporting event is coming to town. Key me
    14·2 answers
  • The part of the computer that contains the brain or the Central Park nursing unit is also known as
    10·1 answer
  • Which attack intercepts communications between a web browser and the underlying computer?
    10·1 answer
  • True or false, USBs are slower than RAM.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!