Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help.
#1
Hi I am a student,since now course include if statement,loops and list. assignment only allow course content.I am struggling for logic pls help me whats best shortest way to find out solution I tried for and while loop but without if statement i am unable to do coding.I know its bit demanding,but I cant get logic at all if some one can help here.thanks in advance.
Write a function called earthquack, this function has 2 arguments. The first is called speed and the second is called units.
The function returns a list containing 2 strings.
The first element of the returned list is a feedback string, which is
one of the following:
‘Inputs are all valid’,
‘Speed not a positive whole number’,
‘The units must be either miles or kilometres’,
‘Both inputs are not valid’.
The second element of the returned list is an empty string if the input
is not valid, otherwise it is one of the following:
‘Not a hurricane’,
‘Category 1 - Very dangerous winds will produce some damage.’ ,
‘Category 2 - Extremely dangerous winds will cause extensive damage.’,
‘Category 3 - Devastating damage will occur.’,
‘Category 4 - Catastrophic damage will occur.’,
‘Category 5 - Catastrophic damage will occur.’
Use lists to store as much of the information as possible. This will
mean you can reduce the number of conditional statements. The simpler your program, the more marks you will receive. If your function
yields the incorrect result for any input, you will get zero marks.
Full marks will only be given for a function that does not use any if
statements. This means that your program uses only indicies of lists
to access the relevant information. Hint, to achieve this you can cast
a boolean to integer, i.e. int(True) is 1 and int(False) is 0.
To find the correct category you can use a while loop.
Examples: (Note quotation marks need to be replaced if you wish to
Reply


Messages In This Thread
Need Help. - by simapatel - Jan-02-2019, 06:26 AM
RE: Need Help. - by ichabod801 - Jan-02-2019, 03:43 PM
RE: Need Help. - by simapatel - Jan-03-2019, 05:49 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020