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]
3 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]3 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 ensures that dropped packets are resent?
Agata [3.3K]

Answer:

TCP

Explanation:

Transmission control protocol ensures packets loss and performs retransmission

TCP works with Internet Protocol (IP)

TCP/IP defines how computers send data packets to each other.

TCP allows transmission of information in both the direction.

Bit rate :defines the rate at which bits are transferred from one place to another

7 0
3 years ago
Find and fix the error in the if-else statement. import java.util.Scanner;
salantis [7]

Answer:

Hi there Rumanruxi! The error is in the if statement "if(userNum = 2)".

Explanation:

The if statement in this Java code is assigning userNum the value of 2 instead of comparing it with the value of 2. For equals comparison we need to write two equals "==" in the statement as: "if (userNum == 2)". This will return true if userNum is 2 otherwise it will return false.  

3 0
3 years ago
Read 2 more answers
What is the portion of the PowerPoint window that contains the current slide, total slides, zoom options, and various shortcuts
telo118 [61]
Normal view is the answer
7 0
3 years ago
Which statement best describes a computer program?
ziro4ka [17]

Answer:

B is the best answer.

Explanation:

All other options listed are related to a program but B beast answers the question.

7 0
2 years ago
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation
Virty [35]

Answer:

The Answer is Desktop Publishing.

Explanation:

Desktop publishing software is one of the tools used by graphic designers as well as non-designers.

It helps in designing visual displays such as brochures, posters, visiting cards, web pages, and desktop printing.

Example:

Corel Draw

Corel Ventura

5 0
3 years ago
Other questions:
  • You have installed a device that has eight interfaces and does not forward broadcast packets. What kind of device did you instal
    6·2 answers
  • Please look at picture
    10·2 answers
  • By issuing concert tickets on the blockchain, fans can verify transfer of ownership from one digital wallet to another, rather t
    14·1 answer
  • JavaScript is the same thing as Java?
    10·2 answers
  • Dayla is concerned about managing her digital footprint. What does she mean by this? *
    7·1 answer
  • Weak Induction
    8·1 answer
  • Which of the following is not a technology that can be used to conserve resources?
    8·2 answers
  • How can you make a search phrase more effective?
    11·1 answer
  • How do i mark brainliest?
    6·2 answers
  • What enforces the location in which an app can function by tracking the location of the mobile device?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!