Computer Science

Find the errors in code given below :

define check()
    N = input ('Enter N: ') 
    i = 3                                             
    answer = 1 + i ** 4 / N                              
    Return answer       

Python Functions

6 Likes

Answer

The errors in the code are:

define check() #Error 1
    N = input ('Enter N: ') #Error 2
    i = 3                                             
    answer = 1 + i ** 4 / N                              
    Return answer #Error 3
  1. The function definition lacks a colon at the end.
  2. The 'input' function returns a string. To perform arithmetic operations with N, it needs to be converted to a numeric type, such as an integer or a float.
  3. The return statement should be in lowercase.

The corrected code is given below:

def check():
    N = int(input('Enter N:'))
    i = 3
    answer = 1 + i ** 4 / N
    return answer

Answered By

3 Likes


Related Questions