26.6k views
4 votes
Which of the following code is correct?

A. print("Programming is fun") print("Python is fun")
B. print("Programming is fun") print("Python is fun")
C. print("Programming is fun) print("Python is fun")
D. print("Programming is fun) print("Python is fun")

User Silvio
by
5.7k points

2 Answers

5 votes

Answer:

a and b

Step-by-step explanation:

User Lukas Bergstrom
by
5.1k points
4 votes

Answer:

The options A and B are correct (as they are the same), assuming that each print function is in different lines.

Step-by-step explanation:

It is assumed that this code is in Python language.

It is important to note that the options A and B are the same because they are equally written. In the same way, the options C and D are the same.

The options C and D are incorrect because the character (") is missing in the first print function. Let's take a look:

print("Programming is fun) <------- The " is missing

If you execute this code, python will generate a "SyntaxError".

On the other hand, the options A and B could be correct or incorrect.

  • It is incorrect if the code is in a single line. If you want to write this code in a single line, you should separate each print function with a semicolon as it follows:

print("Programming is fun"); print("Python is fun")

  • It is CORRECT if the code is in two different lines as follows:

print("Programming is fun")

print("Python is fun")

Thus, the options A and B are correct (as they are the same), assuming that each print function is in different lines.

User Asaf Katz
by
5.7k points