PYTHON
Write some code to read in a sequence of 10 doubles from the keyboard using loops, determine the position of the smallest number in that sequence.
Below is your code:
#declaration of sequence
sequence = []
#loop to get 10 doubles
for x in range(0,10):
num = float(input("Enter a double value: "))
sequence.append(num)
#declaring smallest position
smallPos = 0
#loop to get the smallest position
for x in range(1,len(sequence)):
if sequence[x] < sequence[smallPos]:
smallPos = x
#as in sequence index starts from 0,
#so adding 1 to determine to positon
print("Smallest double is t position:",(smallPos+1))
#printing the smallest value
print("Smallest Value:",sequence[smallPos])
Indentation and output
Get Answers For Free
Most questions answered within 1 hours.