Question

Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab progranms Your Python program will do the following: Create an empty list . Use a for loop to ask the user for 10 numbers. Add each number to your list using the append metha . Use another for loop to print the list in reverse order, one per line . Use a while loop to count how many positive numbers are in the list Here is one example of how the program should look when it runs (user input is in red); Enter a number: 3 Enter a number: 2 Enter a number: 4 Enter a number: 10 Enter a number: 8 Enter a number: 17 Enter a number: 20 Enter a number: 30 Enter a number: -5 Enter a number: 2 Reversed list: -2 -5 30 -20 17 -8 10 Positive count: 5
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the required Program :-

**************************************Program_Starts**********************************************

thisList = []
for x in range(10):
num = int(input("Enter The Number : "))
thisList.append(num)

print("Reversed List : ")
thisList.reverse()
for x in thisList:
print(x)
count = 0
i = 0
while i < 10:
if thisList[i] > 0:
count+=1
i+=1
print("Positive Count : ",count)

********************************Program_Ends*********************************************

Explaination :-

1st loop takes the user input

second loop prints the reverse list

third loop checks for positive integer and prints the output

Output:-

Enter The Number 1 Enter The Number 3 Enter The Number: 4 Enter The Number-6 Enter The Number-7 Enter The Number 5 Enter The Number 6 Enter The Number-9 Enter The Number 3 Enter The Number-4 Reversed List 4 Positive Count 6 5

Add a comment
Know the answer?
Add Answer to:
Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this lab you will convert lab5.py to use object oriented programming techniques. The createList and...

    In this lab you will convert lab5.py to use object oriented programming techniques. The createList and checkList functions in lab5.py become methods of the MagicList class, and the main function of lab6.py calls methods of the MagicList class to let the user play the guessing game.                              A. (4pts) Use IDLE to create a lab6.py. Change the 2 comment lines at the top of lab6.py file: First line: your full name Second line: a short description of what the program...

  • In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while...

    In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while loop or a for loop to print only odd numbers 1, 3, 5, 7, 9 *tip: you can use range () function, or a condition with ‘break’ (e.g, while count < 10) In python!: Create a program that print out 12 months of a year and associated numbers (e.g., January 1, February 2…). Two lists should be created, and then loop through the list...

  • Create a new program in Mu and save it as ps3.4.1.py and take the code below...

    Create a new program in Mu and save it as ps3.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called hide_and_seek. The function should # have no parameters and return no value; instead, when # called, it should just print the numbers from 1 through 10, # follow by the text "Ready or not, here I come!". Each # number and the message at the end should be on its own...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

  • Create a program in Python to change Grades in number and find the GPA of the...

    Create a program in Python to change Grades in number and find the GPA of the user Problem: The user wants an easy calculator to calculate their GPA. They want to enter the letter grade (A, B, C, D, F) for 5 classes, the credit hours (1, 2, 3,4, 5) and then run the program to calculate the GPA (3.50- 4.00 A, 3.49 – 2.50 B, 2.49 -1.60 C, 1.59 – .50 D, .49 -0 F) for the semester. Task...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function,...

    Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function, nbrs_greater that accepts 2 integer lists as a parameters, and returns a list of integers that indicates how many integers in the second list are greater than each integer in the first list. For example: nbrs_greater([3, 4, 1, 2, 7], [10, 1, 4, 2, 5, 3]) returns [3, 2, 5, 4, 1] because: Number of numbers in Element of first list Numbers greater from...

  • Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a...

    Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a file called Numbers.txt in your the same folder as your Python program. This file should contain a list on floating point numbers, one on each line. The number should be greater than zero but less than one million. Your program should read the following and display: The number of numbers in the file (i.e. count them) (counter) The maximum number in the file (maximum)...

  • Write a Python program stored in a file q2.py that asks for a starting number and...

    Write a Python program stored in a file q2.py that asks for a starting number and an ending number, and then prints all the Fibonacci numbers between them (and including the starting and ending numbers, if they are also Fibonacci numbers). Each Fibonacci number, must be separated by a space. Example: Enter starting number : 5 Enter ending number : 500 10 Fibonacci numbers between 5 and 500 are : 5 8 13 21 34 55 89 144 233 377

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT