P
P
Python Classroom
Ask or search…
K

Problems

Problem 1

Create a list named sales. Use a loop to ask the user to enter a store’s sales for 7 days.
Print the total amount of sales.

Sample Output

Problem 2

Create a list named steps. Use a loop to ask the user to enter the number of steps they walk for 5 days. Print the highest, lowest and average number of steps.

Sample Output

Problem 3

Create a list of 5 numbers that contains positive and negative numbers. Print the list. Delete all of the negative numbers. Print the list again.

Sample Output

Problem 4

Create a list of 5 numbers. Print the list. Sort the numbers. Swap the values of the first and last numbers. Print the list.
Do not hard code the last element with list[4]

Sample Output

Problem 5

Create a list of 5 numbers. Print the list. Print the position of the largest element.
Do not hard code the solution. Your solution should work for any list.

Sample Output

Problem 6

Create a list named grades with 5 grades. Print the list. Print the average of the grades.
Sometimes teachers like to drop a student’s lowest grade. Delete the lowest grade and print the new average.
What's the difference between the new average and the original average?

Sample Output

Problem 7

Create a list of 10 positive and negative numbers. Print the list. Print the sum of the positive numbers and the sum of the negative numbers.

Sample Output

Problem 8

Create a list of 10 positive and negative numbers. Print the number of the positive numbers, number of the negative numbers and the number of 0's.

Sample Output

Problem 9

Create a list of 10 positive and negative numbers. Print the average of the positive numbers and average of the negative numbers.

Sample Output

Problem 10

Create a list of 10 numbers that contains positive and negative numbers. Print the list. Print the number of odd numbers, even numbers and zeros.
0 is an even number

Sample Output

Problem 11 (Challenge)

The interquartile range (IQR) is a measure of variability, based on dividing a data set into quartiles.
Quartiles divide a rank-ordered data set into four equal parts. The values that divide each part are called the first, second, and third quartiles; and they are denoted by Q1, Q2, and Q3, respectively.
Q1 is the "middle" value in the first half of the rank-ordered data set. Q2 is the median value in the set. Q3 is the "middle" value in the second half of the rank-ordered data set. The interquartile range is equal to Q3 minus Q1.
For example, consider the following numbers: 1, 3, 4, 5, 5, 6, 7, 11. Q1 is the middle value in the first half of the data set. Since there are an even number of data points in the first half of the data set, the middle value is the average of the two middle values; that is, Q1 = (3 + 4)/2 or Q1 = 3.5. Q3 is the middle value in the second half of the data set. Again, since the second half of the data set has an even number of observations, the middle value is the average of the two middle values; that is, Q3 = (6 + 7)/2 or Q3 = 6.5. The interquartile range is Q3 minus Q1, so IQR = 6.5 - 3.5 = 3.
Create a list of 10 numbers. Find the IQR. Create a list of 11 numbers. Find the IQR. How do your methods differ.