My code is messed up. This is the feedback from my Professor. I am posting my co
ID: 3729061 • Letter: M
Question
My code is messed up. This is the feedback from my Professor. I am posting my code and his feedback. Any help would be appreciated.
I don't see that you submitted a test plan document. [-3 points] Your Pseudocode code is missing all of the indentation. No Python code runs, because main() (the last line of your program) is indented. That makes the call to main() part of main() instead of running it. You want the standalone main() statement at the left margin. The next issue is that you named both a variable and a function "raids_attended". When you "raids_attended = 0" in main(), the raids_attended() function definition is overwritten. raids_attended() also will not run because you defined it with a parameter, but you are not calling it with an argument. Similarly, output_raid_rank() and get_raider_core() are each called without an argument, but you defined each of them as accepting a parameter. The number of values between the parentheses must match - the function definition versus the call to the function. I don't see that you incorporated either of the required loops (a main requirement of Lab 4). Your output list should be raids_attended, rank_points, and raider_core, since those are the variables you are outputting. Indentation is still an issue for your Python "if" blocks. For example, in calculate_rank_points(), you have everything indented after the first "if" statement. That means that the other "if" statements will only execute if raids_attended == 0. You want all of the "if" statements in that function to be at the same indentation level. You'll never return rank_points, because the return statement is conditional that raids_attended == 0 *and* raids_attended > 3 at the same time.
Explanation / Answer
def raids_attended(): raids = input("Enter the number of raids you attended") return raids # Function Integer calculate_raider_points_earned ( Integer raids_attended) # Declare Integer point # If raids_attended == 0 Then # rank_point = 0 # Else If raids_attended == 1 Then # rank_point = 5 # Else If raids_attended == 2 Then # rank_point = 15 # Else If raids_attended == 3 Then # rank_point = 30 # Else If raids_attended > 3 Then # rank_point = 60 # End If # Return rank_point # End Function def calculate_rank_points(raids_attended): rank_points = 0 if int(raids_attended) == 0: rank_points = 0 elif int(raids_attended) == 1: rank_points = 5 elif int(raids_attended) == 2: rank_points = 15 elif int(raids_attended) == 3: rank_points = 30 elif int(raids_attended) > 3: rank_points = 60 return rank_points # Module output_rank(Integer point_earned) # If rank_points == 0 Then # Display " The Raider is a Nub" # If rank_points == 5 Then # Display " The Raider is a casual" # If rank_points == 15 Then # Display " The Raider is a Trial_Raider " # If rank_points == 30 Then # Display "The Raider is a Core_Raider" # If rank_points >30 Then # Display" The Raider is a Slayer" # End If # End Module def output_raid_rank(rank_points): if rank_points == 0: print("The Raider is a Nub") elif rank_points == 5: print("The Raider is a casual") elif rank_points == 15: print(" The Raider is a Trial_Raider") elif rank_points == 30: print("The Raider is a Core_Raider") elif rank_points > 30: print("The Raider is a Slayer") # Function raider_core(Integer rank_points) # Declare String raider_core # If rank_points < 30 Then # Set raider_core = "Not a Core Raider" # Else # Set raider_core = "A Core Raider" # End If # Return raider_core # End Function def get_raider_core(rank_points): get_raider_core1 = "" if rank_points < 30: get_raider_core1 += "Not a Core Raider" if rank_points >= 30: get_raider_core1 += "A Core Raider" return get_raider_core1 # Module raider_rank( Integer raids_attended, Integer rank_points, String raider_core) # Display " The number of raids the Raider attended", raids_attended # Display " The rank points earned is", rank_points # Display " The final raider core is", raider_core # End Module def output_raider_core_info(raids_attended, rank_points, raider_core): print("The number of raids the Raider attended ", raids_attended) print(" The rank points earned is", rank_points) print("The Core Raider Rank is", raider_core) # Module main # Declare raids_attended # Declare rank_points #Declare String raid_rank # Set raids = raids_attended() # set rank_points = () # Set core_raider_rank = core_raider(point) # Call output_point(raids,rank,raider_corps) # Call output_category(rank_points) # End Module def main(): raids = 0 rank = 0 raider_core = "" raids = raids_attended() rank = calculate_rank_points(raids) output_raid_rank(rank) raider_core = get_raider_core(rank) output_raider_core_info(raids, rank, raider_core) main()Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.