menu

Python Input and Output

Python Input and Output - Important Points


1.

Which function is used to take input from the user in Python?

A. input()

B. print()

C. read()

D. scanf()

Discuss Work Space

Answer: option a

Explanation:

The input() function is used to take input from the user in Python.


2. Which function is used to display output in Python?

A. input()

B. display()

C. print()

D. D. show()

Discuss Work Space

Answer: option c

Explanation:

The print() function is used to display output in Python.

3. How do you open a file for writing in Python?

A. file = open("filename.txt", "w")

B. file = open("filename.txt", "r")

C. file = open("filename.txt", "a")

D. D. file = open("filename.txt", "x")

Discuss Work Space

Answer: option a

Explanation:

The "w" mode is used to open a file for writing in Python.

4. How do you open a file for reading in Python?

A. file = open("filename.txt", "r")

B. file = open("filename.txt", "w")

C. file = open("filename.txt", "a")

D. D. file = open("filename.txt", "x")

Discuss Work Space

Answer: option a

Explanation:

The "r" mode is used to open a file for reading in Python.

5. How do you open a file for appending in Python?

A. file = open("filename.txt", "a")

B. file = open("filename.txt", "w")

C. file = open("filename.txt", "r")

D. D. file = open("filename.txt", "x")

Discuss Work Space

Answer: option a

Explanation:

The "a" mode is used to open a file for appending in Python.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now