write an algorithm and flowchart for calculating weight of motor bike in python programming
Answers
Algorithm is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language.
From the data structure point of view, following are some important categories of algorithms −
Search − Algorithm to search an item in a data structure.
Sort − Algorithm to sort items in a certain order.
Insert − Algorithm to insert item in a data structure.
Update − Algorithm to update an existing item in a data structure.
Delete − Algorithm to delete an existing item from a data structure.
Answer:
The algorithm, flowchart and the program are given below
Explanation:
Algorithm:
Algorithms tell the programmers how to code the program. Alternatively, the algorithm can be written as −
step 1 − START COMPUTE
step 2 - Constant price of the motorbike Mb,Mb1
step 3 − Get values of num & num1
step 4 − Total weight ← num*Mb +num1*Mb1
step 5 − display Total weight
step 6 − STOP
Flowchart is given as attachments
Program:
#Python's program to calculate total weight of the order.
#Define the constants
Mb1 = 30000
Mb2 = 40000
#Read the input from user
print("Enter your order items:")
num = int(input(" Number of Motror bike1: "))
num1= int(input(" Number of Motor bike2: "))
#Compute total order weight
total_weight = num*Mb1 + num1*Mb2
#Display the result
print("Your order total weight is:",total_weight,"gm")