Home > other >  Python homework help
Python homework help

Time:10-10

Please use while in python, if, the random how to accomplish these two requirements? Beginner's little harder cry liao ('; ︵; `)

CodePudding user response:

From the random import randint
Try:
Int_top=int (input (' please enter the top number:))
Int_bottom=int (input (' please enter the minimum number:))
If (type (int_top)==STR) or (type (int_bottom)==STR) :
Print (' can't there is Chinese characters! ')
The exit ()

Except:
Print (' cannot have a decimal point! ')
The exit ()

Int_temp=randint (int_bottom int_top)
Print (int_temp)

CodePudding user response:

From the random import randint
Try:
Int_number=int (input (" please enter a title number (not decimal) : '))
Except:
Print (' there can be no decimal! ')
The exit ()
Subject_number=int_number//4
Int_mark=0
Int_error=0
For I in range (int_number) :
If I & lt; Subject_number and I & gt;=0:
Int_1=randint (0, 100
Int_2=randint (0, 100
While int_1 + int_2 & gt; 100:
Int_1=randint (0, 100
Int_2=randint (0, 100
The else:
Int_target=int_1 + int_2
Print (' title: {} + {}=? 'the format (int_1 int_2))
Try:
Input_target=int (input (' please enter the answer: '))
If input_target==":
Print (' have to fill out! ')
The exit ()
Except:
Print (' there can be no decimal! ')
The exit ()
The else:
If input_target==int_target:
Print (' right! ')
Int_mark +=1
Elif input_target!=int_target:
Print (' error! ')
Int_error +=1
Elif I & lt; Subject_number * 2 and I & gt;=subject_number:
Int_1=randint (1, 1000)
Int_2=randint (0, 500
If int_1 & lt; Int_2:
Int_temp=int_1
Int_1=int_2
Int_2=int_temp
While int_1 - int_2 & gt; 100:
Int_1=randint (1, 1000)
Int_2=randint (0, 500
The else:
Int_target=int_1 - int_2
Print (' title: {} - {}=? 'the format (int_1 int_2))
Try:
Input_target=int (input (' please enter the answer: '))
If input_target==":
Print (' have to fill out! ')
The exit ()
Except:
Print (' there can be no decimal! ')
The exit ()
The else:
If input_target==int_target:
Print (' right! ')
Int_mark +=1
Elif input_target!=int_target:
Print (' error! ')
Int_error +=1
Elif I & lt; Subject_number * 3-1 the and I & gt;=subject_number * 2:
Int_1=randint (1, 10)
Int_2=randint (1, 10)
While int_1 * int_2 & gt; 100:
Int_1=randint (1, 10)
Int_2=randint (1, 10)
The else:
Int_target=int_1 * int_2
Print (' title: {} {} *=? 'the format (int_1 int_2))
Try:
Input_target=int (input (' please enter the answer: '))
If input_target==":
Print (' have to fill out! ')
The exit ()
Except:
Print (' there can be no decimal! ')
The exit ()
The else:
If input_target==int_target:
Print (' right! ')
Int_mark +=1
Elif input_target!=int_target:
Print (' error! ')
Int_error +=1
Elif I & lt; Subject_number * 4 and I & gt;=subject_number * 3:
Int_1=randint (2, 1000)
Int_2=randint (1, 100)
While int_1/int_2 & gt; 100:
Int_1=randint (2, 1000)
Int_2=randint (1, 100)
The else:
Int_temp=int_1/int_2
If the type (int_temp)==float:
Int_1=randint (2, 1000)
Int_2=randint (1, 100)
Int_target=int_1 + int_2
Print (' title: {}/{}=? 'the format (int_1 int_2))
Try:
Input_target=int (input (' please enter the answer: '))
If input_target==":
Print (' have to fill out! ')
The exit ()
Except:
Print (' there can be no decimal! ')
The exit ()
The else:
If input_target==int_target:
Print (' right! ')
Int_mark +=1
Elif input_target!=int_target:
Print (' error! ')
Int_error +=1
Print (' you scored {}, {} problem is wrong, '. The format (int_mark int_error))

CodePudding user response:

refer to the second floor weixin_51392495 response:
from the random import randint
Try:
Int_number=int (input (" please enter a title number (not decimal) : '))
Except:
Print (' there can be no decimal! ')
The exit ()
Subject_number=int_number//4
Int_mark=0
Int_error=0
For I in range (int_number) :
If I & lt; Subject_number and I & gt;=0:
Int_1=randint (0, 100
Int_2=randint (0, 100
While int_1 + int_2 & gt; 100:
Int_1=randint (0, 100
Int_2=randint (0, 100
The else:
Int_target=int_1 + int_2
Print (' title: {} + {}=? 'the format (int_1 int_2))
Try:
Input_target=int (input (' please enter the answer: '))
If input_target==":
Print (' have to fill out! ')
The exit ()
Except:
Print (' there can be no decimal! ')
The exit ()
The else:
If input_target==int_target:
Print (' right! ')
Int_mark +=1
Elif input_target!=int_target:
Print (' error! ')
Int_error +=1
Elif I & lt; Subject_number * 2 and I & gt;=subject_number:
Int_1=randint (1, 1000)
Int_2=randint (0, 500
If int_1 & lt; Int_2:
Int_temp=int_1
Int_1=int_2
Int_2=int_temp
While int_1 - int_2 & gt; 100:
Int_1=randint (1, 1000)
Int_2=randint (0, 500
The else:
Int_target=int_1 - int_2
Print (' title: {} - {}=? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related