Home > other >  To solve the
To solve the

Time:09-28

Are now ready to do a small program, the system random 10 sums are given after the user answer system to judge right or wrong, ten questions after a system given scores, please draw a flow chart, how ah

CodePudding user response:

Look at does not meet the full requirements:
 
Import the random


The class AddSystem (object) :
Def __init__ (self, start_num end_num, score=2, question_num=10) :
Self. Start_num=# start_num began to count the randomly generated data
Self. End_num=# end_num randomly generated data by the number of
Self. Question_num=# question_num generated number by default is 10
The self. The score=# score score of every subject, the default is 2

The numerical value range of # arithmetic
Def range_num (self) :
Num=random. Randint (self. Start_num, self end_num)
Return the STR (num)

# random topic, the default is 10
Def rand_question (self) :
Question_list=list ()
For I in range (self. Question_num) :
Question_list. Append (self. Range_num () + "+" + self range_num ())
Return question_list

# output the title and real-time problem, the system real time judgment result
Def output_question (self) :
Sum_score=0
Print (" please calculate the following the results of the formula ")
For question in self. Rand_question () :
Print (question, end='\ t')
User_result=int (input (' results: '))
If user_result==eval (question) :
Print (" right!" )
Sum_score +=self. Score
The else:
Print (f "answer wrong, the correct answer is: {eval (question)}")
Print (f "over, to solve the problem. Your score is: {sum_score}")


If __name__=="__main__" :
Start=int (input (" numerical starting: please enter the title of "))
End=int (input (" please enter the title of numerical deadline: "))
A=AddSystem (start_num=start, end_num=end)
A.o utput_question ()

CodePudding user response:

refer to the second floor Hajo_ response:
look at does not meet the full requirements:
 
Import the random


The class AddSystem (object) :
Def __init__ (self, start_num end_num, score=2, question_num=10) :
Self. Start_num=# start_num began to count the randomly generated data
Self. End_num=# end_num randomly generated data by the number of
Self. Question_num=# question_num generated number by default is 10
The self. The score=# score score of every subject, the default is 2

The numerical value range of # arithmetic
Def range_num (self) :
Num=random. Randint (self. Start_num, self end_num)
Return the STR (num)

# random topic, the default is 10
Def rand_question (self) :
Question_list=list ()
For I in range (self. Question_num) :
Question_list. Append (self. Range_num () + "+" + self range_num ())
Return question_list

# output the title and real-time problem, the system real time judgment result
Def output_question (self) :
Sum_score=0
Print (" please calculate the following the results of the formula ")
For question in self. Rand_question () :
Print (question, end='\ t')
User_result=int (input (' results: '))
If user_result==eval (question) :
Print (" right!" )
Sum_score +=self. Score
The else:
Print (f "answer wrong, the correct answer is: {eval (question)}")
Print (f "over, to solve the problem. Your score is: {sum_score}")


If __name__=="__main__" :
Start=int (input (" numerical starting: please enter the title of "))
End=int (input (" please enter the title of numerical deadline: "))
A=AddSystem (start_num=start, end_num=end)
A.o utput_question ()

To draw flowcharts , the most important

CodePudding user response:

Take the first
"
Take the second
"
The results
"
User input -- -- -- -- -- -- -- "the results of
-- "the wrong score
| |
|
Not scoring |
|
-- "determine whether enough 10 problems
Is that [as a result, not to return to start

  • Related