59.7k views
3 votes
Prompt the user to input an integer between 32 and 126, a float, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space.

User Arun D
by
2.9k points

1 Answer

3 votes

Answer:

In Python:

int_input = int(input("Integer (32 - 126): "))

if int_input>32 and int_input<126:

float_input = float(input("Float: "))

char_input = input("Character: ")[0]

string_input = input("String: ")

print(int_input, end= ' ')

print(float_input, end= ' ')

print(char_input, end= ' ')

print(string_input, end= ' ')

else:

print("Invalid Range")

Step-by-step explanation:

This line prompts user for integer between 32 and 126 (exclusive)

int_input = int(input("Integer (32 - 126): "))

If the integer is within the required range, the program proceeds to prompt the user for more input

if int_input>32 and int_input<126:

This line prompts user for float input

float_input = float(input("Float: "))

This line prompts user for char input

char_input = input("Character: ")[0]

This line prompts user for string input

string_input = input("String: ")

The next 4 lines print the inputs on the same line

print(int_input, end= ' ')

print(float_input, end= ' ')

print(char_input, end= ' ')

print(string_input, end= ' ')

If integer input is outside the range

else:

This prints invalid range

print("Invalid Range")

User Cdauth
by
3.4k points