Home > other >  Small white to change procedures
Small white to change procedures

Time:09-21

Which who can tell me how to change the program on how to correct, I want to use a while loop is the input data to the end of the # and then output the maximum

CodePudding user response:

# # judgment should be in front of the float, string, or can't run, suggest another glue code block,
 num="0" 
Max=0
While (num!="#") :
Num=input (' end of input value, # ')
If num=="#" :
Break
The else:
Num=float (num)
If num> Max:
Max num=
Print (' maximum values for {: 2 f} '. The format (Max))

CodePudding user response:

?? Thank you for your ideas better than my clear

CodePudding user response:

Max is built-in keywords, when the variable name is not recommended!
In addition, as to optimize program and exception handling are needed!
 
Max_digit=0
While True:
Num=input (' input values, # end:)
If num=="#" :
Break
Try:
Num=float (num) # need exception handling
If num & gt; Max_digit:
Max_digit num=
Except:
Print (" current input is not value!" )
Print (f 'maximum values for {max_digit: 2 f}')
  • Related