214k views
2 votes
4.15 LAB: Smallest number

Write a program whose inputs are three integers, and whose output is the smallest of the three values.

Ex: If the input is:

7
15
3
the output is:

3

1 Answer

1 vote

Answer:

The program in Python is as follows:

nums = []

for i in range(3):

num = int(input())

nums.append(num)

nums.sort()

print(nums[0])

Step-by-step explanation:

This initiailizes a list

nums = []

This iteration is repeated for 3 inputs

for i in range(3):

This get input for each iteration

num = int(input())

The input is then appended to the list

nums.append(num)

Sort the list in ascending order

nums.sort()

Print the smallest

print(nums[0])

User Serdar Polat
by
7.6k points