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
Why do astronomers prefer to use the reflecting telescope rather than the refracting telescope to view distant objects in space?
sdas [7]
C is the right answer
7 0
3 years ago
Read 2 more answers
3 features of digital computer​
jolli1 [7]

Answer:

A typical digital computer system has four basic functional elements: (1) input-output equipment, (2) main memory, (3) control unit, and (4) arithmetic-logic unit. Any of a number of devices is used to enter data and program instructions into a computer and to gain access to the results of the processing operation.

Explanation:

6 0
2 years ago
Can someone help me plz
8090 [49]
B = x is equal to 5
and
C = “ have special meaning and should not be used when naming variables “.
3 0
2 years ago
To reduce the number of used digital outputs of the microcontroller, the display board is connected to the main board through th
Luda [366]

Answer:

The program in Python is as follows:

BCD = ["0001","0010","0011","0100","0101","0110","0111"]

num = input("Decimal: ")

BCDValue = ""

valid = True

for i in range(len(num)):

   if num[i].isdigit():

       if(int(num[i])>= 0 and int(num[i])<8):

           BCDValue += BCD[i]+" "

       else:

           valid = False

           break;

   else:

       valid = False

       break;

if(valid):

   print(BCDValue)

else:

   print("Invalid")

Explanation:

This initializes the BCD corresponding value of the decimal number to a list

BCD = ["0001","0010","0011","0100","0101","0110","0111"]

This gets input for a decimal number

num = input("Decimal: ")

This initializes the required output (i.e. BCD value)  to an empty string

BCDValue = ""

This initializes valid input to True (Boolean)

valid = True

This iterates through the input string

for i in range(len(num)):

This checks if each character of the string is a number

   if num[i].isdigit():

If yes, it checks if the number ranges from 0 to 7 (inclusive)

       if(int(num[i])>= 0 and int(num[i])<8):

If yes, the corresponding BCD value is calculated

           BCDValue += BCD[i]+" "

       else:

If otherwise, then the input string is invalid and the loop is exited

<em>            valid = False</em>

<em>            break;</em>

If otherwise, then the input string is invalid and the loop is exited

<em>    else:</em>

<em>        valid = False</em>

<em>        break;</em>

If valid is True, then the BCD value is printed

<em>if(valid):</em>

<em>    print(BCDValue)</em>

If otherwise, it prints Invalid

<em>else:</em>

<em>    print("Invalid")</em>

7 0
3 years ago
1. You have been contracted to design a system for a smart car. The company installed four laser radars on the car’s corners to
Alexxandr [17]

Answer:

A). Using a flowchart, show the algorithm for the car collision avoidance system.

Explanation:

5 0
2 years ago
Other questions:
  • A computer system has a 32KB, 8-way set associative cache, and the block size is 8 bytes. The machine is byte addressable, and p
    7·1 answer
  • Which two actions allow the System Administrator to limit Chatter access during roll-out to a subset of Salesforce users?
    9·1 answer
  • one data is in memory the computer interpets and executeinstructions to process the data into informationA. TrueB. False
    8·1 answer
  • Ile 1 cm<br> ?<br> 50 m<br> The an
    5·2 answers
  • CIST 1122 Project 2 Instructions
    11·1 answer
  • Many of the first photographers were actullay scientists and inventors
    11·1 answer
  • Which shortcut key combination will move the cursor to the beginning of the line?
    13·1 answer
  • So, I have an Cru__ on this boy in school and his name is Bray but Yeah.............Can someone help me
    10·2 answers
  • Documental acerca de los principales materiales que se emplean en la fabricación de medios técnicos utilizados en una oficina.
    9·1 answer
  • What do hard disk drive use to store data
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!