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
I'm stuck on this Java exercise problem and don't know how to organize my code with proper formatting and it's not helping that
Volgvan

In your "count spaces method" before the for loop, you want to declare an int variable (let's call it spc)

then, each time you find that charat, spc++.


also, the string must be declared in the main method, not the spaces count method.


The actual code:


public class CountSpaces{

public static void main(String[] args){

String instring = "(your quote here)";

int spaces = calculateSpaces(instring);

System.out.println("The number of spaces is " + spaces);

}

public static int calculateSpaces(String in){

int spc = 0;

for(int i= 0; i<in.length; i++){

if(in.charAt(i)== ' '){

spc++;

}

}

return spc;

}

}


that should be it.  If you have any questions, feel free to reach out.

4 0
3 years ago
Need help with this
Kryger [21]

Answer:

i say B

Explanation:

because u being professional makes ur company look good

7 0
3 years ago
What is a shot sequence
Elan Coil [88]
A shot sequence is the time between when a shot is shot and when it lands
7 0
4 years ago
In what year was the 1st zelda game released
cluponka [151]
Bro it was realesd in 1997
5 0
3 years ago
Read 2 more answers
What is the difference between Data and information?​
Ksivusya [100]

Answer:

Data is a piece of an Information or a raw form of information while an Information is a processed Data.

Explanation:

An example of Data would be Alphabets of someone's name while the name would be an example of an Information.

On it's own, data makes no sense and needs to be processed to become Information which makes sense.

6 0
3 years ago
Other questions:
  • ________ is the presentation of information to the user and the acceptance of the user’s commands. a.data storageb.data access l
    7·1 answer
  • Technician A says underinflation of a tire causes excessive one-sided wear on one side of the tread. Technician B says overinfla
    11·2 answers
  • Which program, available on all operating systems, provides all types of information from a dns server and allows you to query a
    8·1 answer
  • Consider five wireless stations, A, B, C, D, and E.
    13·1 answer
  • Which term is used to describe bitmap images
    8·2 answers
  • If one department chair—a professor—can chair only one department, and one department can have only one department chair. The en
    13·1 answer
  • .true or false? one disadvantage of cloudware is that it is never free<br> A. true<br> B. false
    12·1 answer
  • Which statement describes part of the meeting scheduling process? It is always an all-day event. It is created in a single calen
    14·1 answer
  • WILL GIVE BRAINLEST!!!!!!!! 10 POINTS!!!!
    5·2 answers
  • 1. Tracy is studying to become an esthetician. Give three reasons why she needs to have a thorough
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!