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
MissTica
3 years ago
11

Write a function called is_even that takes one parameter and returns a boolean value. It should return True if the argument is e

ven; it should return False otherwise.
The is_even function should not print anything out or return a number. It should only take in a number and return a boolean.

Note: Be sure to include comments for all functions that you use or create.

For example, if you made a call like

is_even_number = is_even(4)
is_even_number should have the value True.

Once you’ve written this function, write a program that asks the user for integers and prints whether the number they entered is even or odd using your is_even function. You should let the user keep entering numbers until they enter the SENTINEL value.

Here is a sample run of the program:

Enter a number: 5
Odd
Enter a number 42
Even
Enter a number: -6
Even
Enter a number: 0
Done!

(CODEHS, PYTHON)
Computers and Technology
1 answer:
Nikitich [7]3 years ago
6 0

def is_even_number(n):

   return True if n % 2 == 0 else False

while True:

   number = int(input("Enter a number: "))

   if number == 0:

       break

   else:

       if is_even_number(number):

           print("Even")

       else:

           print("Odd")

I wrote my code in python 3.8. I hope this helps.

You might be interested in
The file extension for Access 2007 and 2010 database filenames is .accdb. What is the file extension for older versions of Acces
Vikentia [17]
<span>The earlier file format was the .mdb file format. If a person has a file that is stored in the .mdb format and gets a new version of Access or needs an upgrade, he or she may choose not to upgrade due to the fact that he or she will not be able to make design changes to the .mdb file.</span>
4 0
4 years ago
If you have a second Ethernet adapter, which network location is being used by the adapter?
yuradex [85]

Answer:

Public network

Explanation:

The network includes different networks and settings for sharing which are applied to the network which you are connected to.

A public network is being used by the adapter. The public network is a network that is unrestrictive. That is, any member of the public can easily have access to it and connect to the internet. Such a network exposed users to risks by exposing the connected devices.

3 0
3 years ago
Write a program with the total change amount as an integer input, and output the change using the fewest coins, one coin type pe
riadik2000 [5.3K]

Answer:

In Python:

cents = int(input("Cents: "))

dollars = int(cents/100)

quarters = int((cents - 100*dollars)/25)

dimes = int((cents - 100*dollars- 25*quarters)/10)

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

if not(dollars == 0):

   if dollars > 1:

       print(str(dollars)+" dollars")

   else:

       print(str(dollars)+" dollar")

if not(quarters == 0):

   if quarters > 1:

       print(str(quarters)+" quarters")

   else:

       print(str(quarters)+" quarter")

if not(dimes == 0):

   if dimes > 1:

       print(str(dimes)+" dimes")

   else:

       print(str(dimes)+" dime")

if not(nickels == 0):

   if nickels > 1:

       print(str(nickels)+" nickels")

   else:

       print(str(nickels)+" nickel")

if not(pennies == 0):

   if pennies > 1:

       print(str(pennies)+" pennies")

   else:

       print(str(pennies)+" penny")

   

Explanation:

A prompt to input amount in cents

cents = int(input("Cents: "))

Convert cents to dollars

dollars = int(cents/100)

Convert the remaining cents to quarters

quarters = int((cents - 100*dollars)/25)

Convert the remaining cents to dimes

dimes = int((cents - 100*dollars- 25*quarters)/10)

Convert the remaining cents to nickels

nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)

Convert the remaining cents to pennies

pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels

This checks if dollars is not 0

<em>if not(dollars == 0):</em>

If greater than 1, it prints dollars (plural)

<em>    if dollars > 1:</em>

<em>        print(str(dollars)+" dollars")</em>

Otherwise, prints dollar (singular)

<em>    else:</em>

<em>        print(str(dollars)+" dollar")</em>

This checks if quarters is not 0

<em>if not(quarters == 0):</em>

If greater than 1, it prints quarters (plural)

<em>    if quarters > 1:</em>

<em>        print(str(quarters)+" quarters")</em>

Otherwise, prints quarter (singular)

<em>    else:</em>

<em>        print(str(quarters)+" quarter")</em>

This checks if dimes is not 0

<em>if not(dimes == 0):</em>

If greater than 1, it prints dimes (plural)

<em>    if dimes > 1:</em>

<em>        print(str(dimes)+" dimes")</em>

Otherwise, prints dime (singular)

<em>    else:</em>

<em>        print(str(dimes)+" dime")</em>

This checks if nickels is not 0

<em>if not(nickels == 0):</em>

If greater than 1, it prints nickels (plural)

<em>    if nickels > 1:</em>

<em>        print(str(nickels)+" nickels")</em>

Otherwise, prints nickel (singular)

<em>    else:</em>

<em>        print(str(nickels)+" nickel")</em>

This checks if pennies is not 0

<em>if not(pennies == 0):</em>

If greater than 1, it prints pennies (plural)

<em>    if pennies > 1:</em>

<em>        print(str(pennies)+" pennies")</em>

Otherwise, prints penny (singular)

<em>    else:</em>

<em>        print(str(pennies)+" penny")</em>

<em>    </em>

4 0
3 years ago
What is the purpose of a register in a CPU? Describe three types of registers.
Ganezh [65]

Answer:

I hope this answer is correct

Explanation:

Internal registers include the instruction register (IR), memory buffer register (MBR), memory data register (MDR), and memory address register (MAR). The instruction register fetches instructions from the program counter (PC) and holds each instruction as it is executed by the processor.

5 0
3 years ago
How much time does a computer take to big calculations ?​
Alex17521 [72]

Answer:

one billion (9 zeros) is being reached fast – 15 seconds. but to get to one trillion (12 zeros) – the difference is amazing – 4 hours and 10 minutes. Basically 1000 times more.

Explanation:

6 0
3 years ago
Other questions:
  • So im leavin brainly....goodbye. (❤´艸`❤)
    13·2 answers
  • Are video games considered information technology
    9·2 answers
  • Question / UJU
    11·1 answer
  • If you want three vertical sections of text on your page, create _____. dividers columns page breaks bulleted lists
    7·2 answers
  • Images are available in many formats, such as tif, bmp, gif, jpeg, and ____.
    5·1 answer
  • Karen wants to create a program that will allow the user to input their age. Which of these lines of code should be used?
    11·1 answer
  • PLEASE HELP ME I WILL GIVE BRAINIEST AND 40 POINTSPython Project Worksheet
    12·1 answer
  • SOMEONE HELP 60 POINTS!!!!! When creating business publications, these two factors must be determined before planning the layout
    8·2 answers
  • What does input allow a computer to do
    14·1 answer
  • In a program you need to store identification numbers of 5 employees and their weekly gross pay.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!