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
dalvyx [7]
3 years ago
11

Write a Python program that prompts the user for the cost of two items to be purchased. Then prompt the user for payment. If the

amount entered is less than the total cost of the two items, print a message that states how much is still owed. Otherwise, print a thank you message and state how much change will be given.
Computers and Technology
1 answer:
Rama09 [41]3 years ago
7 0

Answer:

first_item = float(input("Enter the cost of your first item: "))

second_item = float(input("Enter the cost of your second item: "))

total = first_item + second_item

payment = float(input("Enter the amount you will be paying: "))

if payment < total:

   print("You still owe: " + str(total - payment))

else:

   print("Thank you. You will receive " + str(payment - total))

Explanation:

- Get the item costs from the user

- Calculate the <em>total</em>

- Get the <em>payment</em> from the user

- Compare the <em>payment</em> and <em>total </em>and print the appropriate message

You might be interested in
Assuming a user enters 25 as input, what is the output of the following code snippet? int i = 0; Scanner in = new Scanner(System
Dmitry_Shevchenko [17]

Answer:

The correct answer for the given question is 24

Explanation:

In the given  question the value of variable i entered by the user is 25 i.e the value of i is 25 control checks the condition of if block which is false .So control moves to the else block and executed the condition inside the else block means it executed i-- decrements the value of i by 1 means i is 24

Following are the program of java :

import java.util.*;// import package

public class Main // main class

{

// main method

public static void main(String[] args)

{

int i = 0;  // variable declaration

Scanner in = new Scanner(System.in); // creating class of scanner class

System.out.print("Enter a number: ");

i = in.nextInt();  //  user input

if (i > 25)  // check if block

{

i++; // increment the value of i

}

else

{

   i--; // decrement the value of i

}

System.out.println(i);  // display i

}

}

Output:

Enter a number:25

24

8 0
4 years ago
Two electronics technicians are looking at the piece of testing equipment shown in the figure above. Technician A says that this
finlep [7]
Correct answer is B. had this question in the past
5 0
3 years ago
Which are examples of embedded systems? Choose two answers.
SVEN [57.7K]

Answer:

An operating system inside a virtual machine

Smart TVs

Explanation:

We can explain an embedded systems like a system within other system, in this case we have two examples, the smart TV have an operative system in some cases an Android system, and this system is within the television system, the virtual machine is the same concept, we can have an Android system running in a windows system.

7 0
3 years ago
Let A be an array of n numbers. Recall that a pair of indices i, j is said to be under an inversion if A[i] &gt; A[j] and i &lt;
AysviL [449]

Answer:

Check the explanation

Explanation:

#include <stdio.h>

int inversions(int a[], int low, int high)

{

int mid= (high+low)/2;

if(low>=high)return 0 ;

else

{

int l= inversions(a,low,mid);

int r=inversions(a,mid+1,high);

int total= 0 ;

for(int i = low;i<=mid;i++)

{

for(int j=mid+1;j<=high;j++)

if(a[i]>a[j])total++;

}

return total+ l+r ;

}

}

int main() {

int a[]={5,4,3,2,1};

printf("%d",inversions(a,0,4));

  return 0;

}

Check the output in the below attached image.

5 0
3 years ago
Write a program that asks for the names of three runners and the time, in minutes (no seconds, etc.), it took each of them to fi
Crank

Answer:

Complete python code with explanation and output results is given below

Explanation:

User is asked to input names of runners and their finishing time

We have to determine first, second and third according to their finishing time.

if else conditioning is used to determine who has lowest finishing time.

Outer if is used to decide first position and inner if is used to decide second and third position.

str() function is used to concatenate the integer variable with string

Code:

runner1 = input("Please enter name of the runner1 ")

time1 = int(input("Please enter the time of runner1 "))

runner2 = input("Please enter name of the runner2 ")

time2 =int(input("Please Enter name of the runner2 "))

runner3 = input("Please enter name of the runner3 ")

time3 =int(input("Please Enter name of the runner3 "))

if(time1 < time2 and time1 < time3):  

   if(time2 < time3): // to decide 2nd and 3rd position

       print(runner1+" has finished First with time: "+str(time1))

       print(runner2+" has finished Second with time: "+str(time2))

       print(runner3+" has finished Third with time: "+str(time3))

   else:

       print(runner1+" has finished First with time: "+str(time1))

       print(runner3+" has finished Second with time: "+str(time3))

       print(runner2+" has finished Third with time: "+str(time2))

if(time2 < time1 and time2 < time3):  

   if(time1 < time3):

       print(runner2+" has finished First with time: "+str(time2))

       print(runner1+" has finished Second with time: "+str(time1))

       print(runner3+" has finished Third with time: "+str(time3))

   else:

       print(runner2+" has finished First with time: "+str(time2))

       print(runner3+" has finished Second with time: "+str(time3))

       print(runner1+" has finished Third with time: "+str(time1))

if(time3 < time1 and time3 < time2):

   if(time2 < time1):    

       print(runner3+" has finished First with time: "+str(time3))

       print(runner2+" has finished Second with time: "+str(time2))

       print(runner1+" has finished Third with time: "+str(time1))

   else:

       print(runner3+" has finished First with time: "+str(time3))

       print(runner1+" has finished Second with time: "+str(time1))

       print(runner2+" has finished Third with time: "+str(time2))

Output:

Program has been tested with multiple inputs and results are accurate as per problem specifications.

Please enter name of the runner1 danny

Please enter the time of runner1  45

Please enter name of the runner2  sam

Please enter the time of runner2  34

Please Enter name of the runner3  tedd

Please enter the time of runner3  23

tedd has finished First with time: 23

sam has finished Second with time: 34

danny has finished Third with time: 45

5 0
4 years ago
Other questions:
  • In databases and database-related software, which choice is not a Boolean operator?
    7·2 answers
  • How computational thinking skills impact software design and the quality of the software applications produced?
    10·1 answer
  • Sara works in the IT department for a large retail store. She has been testing a theory about why an error message keeps popping
    14·1 answer
  • Consider the following relationship involving two entities, students and classes:A student can take many classes. A class can be
    9·1 answer
  • Which of these is an aggregator?
    5·2 answers
  • Typical business cards in the U.S. are _____.
    5·1 answer
  • A non technical kind of cyber intrusion that relies heavily on human interaction and often involve tricking people into breaking
    5·1 answer
  • Rob used Track Changes to suggest changes in Jack's document. Jack agrees with some edits and disagrees with others. What should
    14·1 answer
  • Identify the technique to free up the CPU by allowing device controllers to independently transfer data between the device and m
    7·1 answer
  • What is the full form of MPEG?<br> The full form for MPEG is ________.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!