0

Python comparison question - HELP!!

Can anyone help me with that question for the video game score? “The given code fragment for a video game checks if the player is ready for the next level. Only players with a score greater than 100 can move to the next level.   Task Complete the code to display True when the score is greater than 100 and False otherwise” I can do it for the first score, but I don’t know how to do it to integrate the second score

19th Apr 2024, 2:11 AM
Lori White
9 Answers
+ 3
Can you show your code attempt like the following guide explains: https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app Also, keep in mind that you probably need to accept input, not hard code the variables for the "score".
19th Apr 2024, 8:10 AM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Lori White , This part is wrong. # The program takes the score as an input score = int(120) score = int(95) What you (probably unintentionally) did there is not take any input but instead convert 120 to an int (which is unnecessary, since 120 is already an int) and assign 120 to score. Then you reassigned score the value 95. Delete those statements. Only take one input, and don't hard-code the value. Assume that the input is unknown. Each test case will run your program again and send it a different input. Without giving you the exact syntax, you'll need to call input() to get the input. You'll need to call int() to convert the return value of input, which is a str, to an int. You'll need to assign the return value of int() to score. It's possible to do all that in one statement. Your print statement is correct. # Add the comparison operation inside the parentheses print(score > 100)
19th Apr 2024, 5:32 PM
Rain
Rain - avatar
+ 2
Alan Moreno , Sending a prompt-text argument to the input function when you call it should be avoided on Sololearn. 1. When a user uses your program, Sololearn makes them enter all inputs before running the program, meaning that they won't see the prompt until it isn't needed anymore, making it useless. 2. If a Code Coach runs your program, it will be expecting a certain output for each test case, and nothing more. However it will see the prompt text too, which will cause it to score your program's output as incorrect. 3. Sololearn never teaches about the prompt text, probably for the first two reasons. It's just an unfortunate idea that keeps getting passed from user to user and won't die.
20th Apr 2024, 5:32 AM
Rain
Rain - avatar
+ 2
Thank you!! I get it now, finally
21st Apr 2024, 10:38 PM
Lori White
+ 1
Its basically same as how you do the first score, but depends in your case. If its in separate variables, just do it like the first one, but do it with the second one, like: assume s1 is first score, s2 is second score, and assuming it should also include 100, not just above 100... s1 >= 100 # will return True s2 >= 100 # will also return True If its in an array: assume sA is the array of scores sA[0] >= 100 # will return True if first score is 100 or above sA[1] >= 100 # will return True if second score is 100 or above
19th Apr 2024, 2:27 AM
Marc John Oclinaria Benamera
Marc John Oclinaria Benamera - avatar
+ 1
Marc John Oclinaria Benamera , Note that the description says "greater than 100", not "greater than or equal to 100".
19th Apr 2024, 9:15 AM
Rain
Rain - avatar
+ 1
It seems like you want to compare two scores to check if each is greater than 100, and then print `True` if they are and `False` if they're not. However, your current implementation only assigns the value `95` to the variable `score`, effectively overwriting the previous value `120`. Let me guide you on how to correct it. You need to take two scores as inputs and then check each score separately. Here's how you can modify your code: ```Code in Python: # Take two scores as input score1 = int(input("Enter the first score: ")) score2 = int(input("Enter the second score: ")) # Check if each score is greater than 100 and print the result print("Score 1 result:", score1 > 100) print("Score 2 result:", score2 > 100) ``` With this modification, you'll be prompted to enter two scores, and the program will print `True` if each score is greater than 100 and `False` otherwise.
20th Apr 2024, 3:03 AM
Alan Moreno
Alan Moreno - avatar
0
This is what I have. It wants me to enter two scores, but I keep getting an error. # The program takes the score as an input score = int(120) score = int(95) # Add the comparison operation inside the parentheses print(score > 100)
19th Apr 2024, 4:29 PM
Lori White
0
Mithil Kumar please don't paste irrelevant information or codes. This has been reported for removal.
20th Apr 2024, 3:21 PM
Ausgrindtube
Ausgrindtube - avatar