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
Grace [21]
2 years ago
12

Write a function number_of_pennies() that returns the total number of pennies given a number of dollars and (optionally) a numbe

r of pennies. Ex: If you have $5.06 then the input is 5 6, and if you have $4.00 then the input is 4. Sample output with inputs: 5 6 4 506 400
Computers and Technology
2 answers:
KonstantinChe [14]2 years ago
7 0

Answer:

Code is given as:-

#number_of_pennies function with one default argument with pennies as 0 when no pennies parameter is given

def number_of_pennies(dollars,pennies = 0):

  pennies = dollars*100 + pennies #one dollar equals 100 pennies so calculate total pennies with this formula

  return pennies #return total pennies

print(number_of_pennies(int(input()),int(input()))) #both Dollars and pennies

print(number_of_pennies(int(input()))) #Dollars only

Explanation:

Here is the sample code and output.

katovenus [111]2 years ago
5 0

Answer:

The function is as follows:

def number_of_pennies(dollars,pennies=0):

   return dollars*100+pennies

   

Explanation:

This defines the function

def number_of_pennies(dollars,pennies=0):

This returns the number of pennies

   return dollars*100+pennies

<em>Note that, if the number of pennies is not passed to the function, the function takes it as 0</em>

You might be interested in
Describe the difference between a chained conditional and a nested conditional. Give your own example of each.
I am Lyosha [343]
Here you go :) have a good day :))))

5 0
2 years ago
Write a function swap that swaps the first and last elements of a list argument. Sample output with input: 'all,good,things,must
zubka84 [21]

Answer:

li=list(map(str,input().strip().split()))#taking input of the string.

#swapping first and last element.

temp=li[0]

li[0]=li[-1]

li[-1]=temp

print(li)#printing the list.

Explanation:

I have taken the list li for taking the input of strings.Then after that swapping first and last element of the list.Then printing the list.

7 0
3 years ago
Read 2 more answers
The count function is used to total the values stored in numeric columns.
Dovator [93]

Answer : False.

The function to total the values stored in numeric columns is the SUM function.

5 0
3 years ago
Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum;
kkurt [141]

Answer:

522

Explanation:

5 0
3 years ago
What happens if i unplug my alarm system?
Dafna11 [192]
It loses power and most likely stops working
6 0
3 years ago
Other questions:
  • Which of the following statements is true of ASCII code?
    12·1 answer
  • Please help me answer this question
    14·1 answer
  • ___ is an example of a function prototype.
    12·1 answer
  • Function Name: d2x Parameters: int, int Returns: string Description: Write function, d2x, that takes as input a nonnegative inte
    10·1 answer
  • Which of the following is true of the poka-yoke approach used for mistake-proofing processes?
    9·2 answers
  • Evie clicks through her presentation slides and realizes they all have transition effects coming from the same location, from th
    13·1 answer
  • What are TWO examples of soft skills?
    11·1 answer
  • Why is drive of value when pursuing a career in IT?
    14·1 answer
  • Mention how to install antivirus software in your computer, either by following the instructions given on installation CDs or we
    6·1 answer
  • How to transfer polygon from eth to polygon in ledger live
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!