Lab 07
Lab 07
ASSIGNMENT
Lab # 07
Error:
The function definition is incorrect. In Python, you need to use the def keyword to define a function, and
the function body should be properly indented. Also, the arguments should be enclosed in
parentheses.In Python, after defining a function or starting a loop or conditional statement (if, while,
for), you should use a colon (:) to indicate the start of the block. Python uses indentation to define
blocks of code, such as function bodies, loops, and conditional statements. The content of the function
should be indented. The return statement should also be properly indented inside the function.
Corrected Code:
Output:
Er
ror:
The function definition is missing the def keyword to properly define a function in Python. After
defining a function in Python, you should use a colon (:) to indicate the start of the function body. String
concatenation should be done using + correctly, with spaces added where necessary for readability.
Corrected Code:
Output:
3. Code:
Error:
The condition i // 2 == 0 checks if i divided by 2 equals 0. This condition will always be False for
any integer because it checks if i is even, rather than if the remainder when i is divided by 2 is 0 (which
indicates evenness).
Corrected Code:
Output:
Output:
Output:
Output:
Source Code:
Output:
Source Code:
Output:
Source Code:
Output:
Source Code:
Output: