This repository was archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_a_program.py
More file actions
32 lines (27 loc) · 1.39 KB
/
Copy pathdebug_a_program.py
File metadata and controls
32 lines (27 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Debug/fix the following program so that it shows the indicated output
# TODO: Fixed spacing, personally I hate spaces, so I use <TAB> which saves time to get around scripts, and makes code easier to see for others
# TODO: This is a dangerous way to get user input, I would strongly recommend against trusting raw user input
# FIXME: Since you are getting user input and expecting an integer, you must cast to an integer int()
num = int(input("Please enter a number: "))
# FIXME: Added parameter 'num' to function
def isEven(num):
# FIXME: If statement requires : after the condition
# FIXME: Invalid syntax, requires conditional comparation operator (==), not assignment operator (=)
if (num % 2 == 0):
# FIXME: Misspelled 'return' and remove : after the value to return
return True
# FIXME: Removed obsolete code that isn't nessesary for the 'else' statement. Switched to 'else' over 'elif' since you are only returning a boolean
else:
return False
def main():
# FIXME: Invalid syntax, ';' and ',' is not used, use %(var) to pass in arguments.
# FIXME: Function call is incorrect, should be 'isEven()'
# FIXME: Missing closing ')' for function call to 'print()'
print ("The number %i is even: %s" %(num, isEven(num)))
# FIXME: Requires () to call a function
main()
# FIXME: Removed "=== OUTPUT ===" since this is not from the direct program output
"""'
Enter a number: 5
The number 5 is even: False
"""