Question

PYTHON Write some code to read in a sequence of 10 doubles from the keyboard using...

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.

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a python program to determine the smallest number in a sequence and illustrate it with...
Write a python program to determine the smallest number in a sequence and illustrate it with a table showing the values of the variables for each step. use the sequence​ {7,5,3,2,4}
Write a MARIE assembly program to read three different positive numbers from the keyboard and output...
Write a MARIE assembly program to read three different positive numbers from the keyboard and output the difference between the largest and smallest numbers to the screen.
Create a c file to read a character from the keyboard and write it to a...
Create a c file to read a character from the keyboard and write it to a file. please help
The following code to run as the described program on python. The extra test file isn't...
The following code to run as the described program on python. The extra test file isn't included here, assume it is a text file named "TXT" with a series of numbers for this purpose. In this lab you will need to take a test file Your program must include: Write a python program to open the test file provided. You will read in the numbers contained in the file and provide a total for the numbers as well as the...
12) Using the code in question 8: Write the python statement which will remove both the...
12) Using the code in question 8: Write the python statement which will remove both the key ‘gpa’ and its value 2.8 from s2 13) True or False? A dictionary is a set of items; each item consists of a colon-separated key and value. Each item is separated from other items using a comma. Dictionaries may contain both simple and complex data types. A dictionary may contain data about a single object. Another dictionary may contain data about multiple objects....
please write a LONG basic piece of code in Python language that focuses on using Variables,...
please write a LONG basic piece of code in Python language that focuses on using Variables, please do not make the code short! thank you!
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
IN JAVA: Write code (using ArrayLists) to read a line of input from the user and...
IN JAVA: Write code (using ArrayLists) to read a line of input from the user and print the words of that line in sorted order, without removing duplicates. For example, the program output might look like the following: Type a message to sort: to be or not to be that is the question Your message sorted: be be is not or question that the to to
Using Python, write the following code. You are to allow the user to enter the daily...
Using Python, write the following code. You are to allow the user to enter the daily temperature as a floating-point number. You should make the assumption that you are recording temperatures in Fahrenheit. You should allow the user to continue entering temperatures until the value -999 is entered. This number should not be considered a temperature, but just a flag to stop the program. As the user enters a temperature, you should display the following each time: Current Temperature: 999...
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT