I am a newbie to Python and trying to find the greatest number below a given number. Under normal circumstances I would use lists like in the link below: Select the greatest number below a given number using LINQ to Objects?
However, we are only allowed to use while and for loops, if/elif states, and functions. We cannot use lists.
Basically, the problem is as follows:
- Prompt user to enter a positive integer x.
- Find the highest value v that is less than or equal to the number x and its corresponding alphabet letter n:
Value (v) Letter (n) 1 a 4 b 5 c 9 d 10 e 40 f 50 g 90 h 100 i
This is the first part and it has me stuck. I was thinking of using the partial code below but I am not sure if it is going in the right direction.
assume x = 29
y= 1
while y <= x
if y <= x
y = 4
elif y = 1
The problem I am having is how to do continue checking the entire list of numbers (1,4,5,9,10, etc.) Any suggestions is appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire