3 Python Print Flashcards

1
Q

What is the purpose of the print function in Python?

A

print is a built-in function used to display messages or values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the syntax for using the print function?

A

Use lowercase print followed by parentheses containing the content to display.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Provide an example of using the print function with a number.

A

print(10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Provide an example of using the print function with a string.

A

print(“Hello World”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What file extension is used for Python files?

A

.py

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What happens if there is a syntax error in Python?

A

The IDE flags errors with red lines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can single quotes and double quotes be used interchangeably for strings in Python?

A

Yes, both can be used interchangeably.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False: The print function can only handle string data.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are triple quotes used for in Python?

A

Triple quotes are used for multi-line strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the role of the print function in learning Python?

A

print serves as a starting point for displaying output and debugging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is one key difference between Python 2 and Python 3 regarding print?

A

In Python 2, print is a statement; in Python 3, it is a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Fill in the blank: The print function has an optional parameter called _______ that defines the separator between multiple arguments.

A

sep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the end parameter in the print function do?

A

Defines what is printed at the end of the output, defaults to a newline.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you print multiple arguments using the print function?

A

Pass several items separated by commas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the effect of calling print() with no arguments?

A

It prints just a newline.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are f-strings in Python?

A

Formatted string literals for more complex output.

17
Q

What does PEP 8 recommend for naming conventions in Python?

A

Use lowercase letters and underscores for file names.

18
Q

What is the return value of the print function?

19
Q

How do beginners often use the print function?

A

For debugging purposes.

20
Q

What are docstrings in Python?

A

Documentation strings for modules, classes, and functions.