Python Programming - Console Input/Output

Exercise : Console Input/Output - General Questions
  • Console Input/Output - General Questions
11.
Which function is used to print without a newline?
print_no_newline()
print(newline=False)
print("\n", end="")
print_n()
Answer: Option
Explanation:
To print without a newline in Python, you can use print("\n", end="").

12.
How can you read a floating-point number from the console?
read_float()
float(input())
input().to_float()
parse_float(input())
Answer: Option
Explanation:
To read a floating-point number from the console in Python, you can use float(input()).

13.
How can you prompt the user with a message and read an integer in a single line?
prompt_integer()
input("Enter an integer: ").to_int()
int(input("Enter an integer: "))
user_prompt("Enter an integer: ").read_integer()
Answer: Option
Explanation:
To prompt the user with a message and read an integer in a single line, you can use int(input("Enter an integer: ")).

14.
How can you read a list of integers from the console?
list(input().split())
int_list = input().to_list()
list(map(int, input().split()))
read_integer_list()
Answer: Option
Explanation:
To read a list of integers from the console, you can use list(map(int, input().split())).

15.
What is the purpose of the sep parameter in the print() function?
Sets the output separator between arguments
Sets the end character at the end of the printed string
Controls the formatting of the printed string
Defines the width of the printed string
Answer: Option
Explanation:
The sep parameter in print() sets the output separator between the arguments.