Computer Science, asked by Anonymous, 1 month ago

Language : Python
▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Write a program to take input for opening quantity, received quantity, issued quantity and calculate closing quantity. Program should not accept any zero or negative value for opening/received/issued quantity.

✍️ Formula of closing quantity.
★ Closing quantity = Opening quantity + Received quantity - Issued quantity.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬
I have created the program but it's not working. Please see the mistake and correct it.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Códe of my program :
o = float(input("Enter opening quantity : "))
r = float(input("Enter recieved quantity : "))
i = float(input("Enter issued quantity : "))
if (o or r or i <= 0):
print("Kindly enter only positive value !")
else :
c = o + r - i
print("The closing quantity is",c)

⚠️ Take care of block and indentation. [You can see the attached images for clarification]

▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Attachments:

Answers

Answered by Anonymous
19

Given còde :-

o = float(input("Enter opening quantity : "))

r = float(input("Enter recieved quantity : "))

i = float(input("Enter issued quantity : "))

if (o or r or i <= 0):

‎ ‎ ‎print("Kindly enter only positive value !")

else :

‎ ‎ ‎c = o + r - i

‎ ‎ ‎print("The closing quantity is",c)

Below is the corrected còde :-

o = float(input("Enter opening quantity : "))

r = float(input("Enter recieved quantity : "))

i = float(input("Enter issued quantity : "))

if ( o or i or r )<=0:

‎ ‎ print("Kindly enter only positive value !")

elif( o and r and i) > 0 :

‎ ‎ ‎c = o + r - i

‎ ‎ ‎print("The closing quantity is",c)

[I have added some blank spaces in the program to render the correct ìndentations. Don't còpy and pàste the whole as it is because blank spaces will throw an error.]

What's the error?

Your program was almost correct but there was a minor mistake. You must add correct parenthesis ( ) . It was not working properly because of incorrect parenthesis insertion.

Both the program and output are attached . . . ★

Attachments:
Similar questions