Late but great and to the point here. The only flaw I see is that with your if statement for your choice variable. The loop will continue with any answer other than 'n'. So I can put in value there, and it won't result in an error. Maybe implement an exception?
Here is my code. I am a beginner in Python so any feedback is greatly appreciated :) sum = 0.0 num_count = 0 while True: x= float(input("Enter your number: ")) num_count += 1 sum += x choice= input("Do you want to add another number? (y/n): ") if choice.lower() == "n": break print(f"Sum: {sum:.2f}.") print(f"Average: {sum/num_count:.2f}.")
use a variable to count the number of input. with every input increase it and check whether you have crossed 100 entries. if so then stop taking input.
thank you sir but i have one problem the compiler does not show errors but the program does not want to calculate the average something about float or something
Late but great and to the point here. The only flaw I see is that with your if statement for your choice variable. The loop will continue with any answer other than 'n'. So I can put in value there, and it won't result in an error. Maybe implement an exception?
yes. that can be done :)
very good ,you explain very good!
Thank you! 😃
Why we are converting the user data into lower case ie. If condition
Here is my code. I am a beginner in Python so any feedback is greatly appreciated :)
sum = 0.0
num_count = 0
while True:
x= float(input("Enter your number: "))
num_count += 1
sum += x
choice= input("Do you want to add another number? (y/n): ")
if choice.lower() == "n":
break
print(f"Sum: {sum:.2f}.")
print(f"Average: {sum/num_count:.2f}.")
good :)
When v run the program in the end of program i dont get numbers s value, it directly exit.
Plz help
How the code be like if we want to limit the user to input numbers not more than 100 times?
use a variable to count the number of input.
with every input increase it and check whether you have crossed 100 entries. if so then stop taking input.
Thanks sir
Welcome
how to find the sum of series for integer value of n
thank you sir but i have one problem the compiler does not show errors but the program does not want to calculate the average something about float or something
if the input is 2 ?
sum will be 2
average will be 2
@@ExampleProgram
here 2 will be input and
Output
24
2+22
Why are Indians' classes always better?
Yes
fr lol
Brother I need your help,please reply so that I can message you on Facebook 🎆
you can post your query here :)
@@ExampleProgram drive.google.com/file/d/1bCVs-j6ueeKeoRGvPcauiawDFWTArm60/view?usp=drivesdk
you can't explain well