0% found this document useful (0 votes)
2 views2 pages

Understanding Compile Time Errors in Python

Uploaded by

Kiana Vahedinia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Understanding Compile Time Errors in Python

Uploaded by

Kiana Vahedinia
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

HOMEWORK ASSIGNMENT:

PROGRAMMING ERRORS

Compile Time Errors: Errors that occur in your code that prevents the code from compiling
(being able to run)

Most common compile time errors are


 Trying to access variable that do not exist
 Misspelling a variable name
 Forgetting a semi colon in an if/elif/else statement
 Writing if/elif without an else
 Trying to add ints with Strings

Run Time Errors: Errors that occur while the program is running

Most common run time error is entering a String when it we should be receiving an int

PART I: Each of the following lines of code contains errors. For each line of code, circle
the errors and re-write the correct line of code in the space provided.

1. print(“I LOVE PYTHON”


_____________________________________________________________________

2. age = “1”6
_____________________________________________________________________

3. print(OLQW)
_____________________________________________________________________

4. PRINT(“Hello world!”)
_____________________________________________________________________

5. print(“My name is:” name)


_____________________________________________________________________

6. print(num1 * num2 = num3)


_____________________________________________________________________
PART II: Copy the following code into a blank Python. When you compile and try to run the
program, you will be notified of several compile-time errors. Correct each error until
the program compiles and runs properly.

# Prompt user for the first number


x = in(input(Please enter the first number))

# Prompt user for second number


y = INT(input(“Please enter the first number”))::

# Calculate sum
sum = x + y

# Output the sum


Print(x + y + “=” + sum)

You might also like