answer.
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
pogonyaev
3 months 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:
8_murik_8 [964]3 months ago
6 0

Answer:

Below is the month_days function:

def month_days(month, days):

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

You can invoke this function with arguments like:

month_days ("June", 30)

month_days("July", 31)

The function can also be restructured as follows:

def month_days(month, days):

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

To view the output, call the function along with print like this:

print(month_days ("June", 30))

print(month_days("July", 31))

Explanation:

The defined month_days function takes two parameters: the month name and the number of days in that month. It has a return statement return (month +" has " + str(days) + " days.") which combines the month name held in the variable month with the word "has" and then the number of days stored in days followed by the term days.

For instance, if "June" is passed in as month and 30 as days, the output will be:

June has 30 days.

This program can also be constructed using an f-string for better formatting in the month_days function:

def month_days(month, days):

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

   return (output)

To see the output, invoke the function with print:

print (month_days("June", 30))

print (month_days("July", 31))

The f-string starts with 'f' and includes the parameters month and days within curly braces. The variables month and days are substituted with their respective values when the function is called.

Screenshot of the program and its output is attached.

You might be interested in
A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
zubka84 [1067]
The answer is back up
8 0
1 month ago
Read 2 more answers
Which correctly lists the two elements that make up the empty space in the universe? ice and debris debris and dark matter dark
Rzqust [1037]
The correct response is "dark matter and dark energy and dust." Explanation: In the vast emptiness of the universe, it’s filled with gases and residuals. While humans may perceive the empty space as devoid of contents, it includes plasma hydrogen and helium gases, in addition to various types of dirt and remnants. There's a variety of other materials, but greenhouse gases and dust comprise the majority.
5 0
1 month ago
Read 2 more answers
CodeLab Question
Rzqust [1037]

Response:

I am not familiar with coding languages, but I can demonstrate how you might do it in Python

myAlarm():

   arm = True

   code = "secret message"

myAlarm()

main():

deactivate = input(">>> ")

if deactivate = myAlarm.code:

  arm = False

I still feel a bit unclear about the question.

(I work as a game developer and code daily)

3 0
2 months ago
The Domain Name System (DNS) provides an easy way to remember addresses. Without DNS, how many octets for an Internet Protocol (
Harlamova29_29 [1022]

Response:Four

Clarification:

The Domain Name System (DNS) serves as a naming framework, linking the names individuals use to find websites to the corresponding IP addresses utilized by computers to locate those websites. This system interacts with either the Internet or a private network.

An IP address, represented as a 32-bit binary number, is typically presented in a standard format as 4 octets in decimal notation for easier human comprehension.

6 0
2 months ago
In Section 8.5.4, we described a situation in which we prevent deadlock by ensuring that all locks are acquired in a certain ord
8_murik_8 [964]

Answer:

Refer to Explanation

Explanation:

Dividing this critical section into two parts:

void transaction(Account from, Account to, double amount)

{

Semaphore lock1, lock2;

lock1 = getLock(from);

lock2 = getLock(to);

wait(lock1);

withdraw(from, amount);

signal(lock1);

wait(lock2);

deposit(to, amount);

signal(lock2);

}

This approach is optimal in practice, as separating the critical section avoids any unintended states (for instance, resulting in withdrawing more funds than available).

The straightforward solution of keeping the critical section intact lies in ensuring that locks are acquired in the same order across all transactions. In this scenario, the locks can be sorted, choosing the smaller one to lock first.

4 0
2 months ago
Other questions:
  • Which of the following statements is true regarding input and output?
    12·2 answers
  • Explain how abstraction is used in a GPS system
    12·2 answers
  • Write a statement that reads a floating point value from standard input into temperature. Assume that temperature. has already b
    6·1 answer
  • Which is among the earliest formats of audio used in video games? A. MP3 B. wave table synthesis C. pulse code modulation D. MOD
    7·2 answers
  • Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
    14·1 answer
  • You are a police officer trying to crack a case. You want to check whether an important file is in the evidence room. Files have
    5·2 answers
  • A company requires an Ethernet connection from the north end of its office building to the south end. The distance between conne
    8·1 answer
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • Asia pacific and Japanese sales team from cloud kicks have requested separate report folders for each region.The VP of sales nee
    14·1 answer
  • Which of the following is true of how packets are sent through the internet?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!