Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PHYTON PLEASE 1. A triangular number is a number that is the sum of the integers from 1 to some integer n. Thus 1 is

PHYTON PLEASE

1.

A triangular number is a number that is the sum of the integers from 1 to some integer n. Thus 1 is a triangular number because it's the sum of the integers from 1 to 1; 6 is a triangular number because it's 1+2+3=6.

Given the non-negative integer n, create a list of the first n triangular numbers. Thus if n was 5, the list would be: [1, 3, 6, 10, 15]. Associate the list with the variable triangulars.

2.

An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers is the same. This in the sequence 1, 3, 5, 7, ..., the distance is 2 while in the sequence 6, 12, 18, 24, ..., the distance is 6.

Given the positive integer distance and the non-negative integer n, create a list consisting of the arithmetic progression between (and including) 1 and n with a distance of distance. For example, if distance is 2 and n is 8, the list would be [1, 3, 5, 7].

Associate the list with the variable arith_prog.

3. Given a variable temps that refers to a list, all of whose elements refer to values of type float, representing temperature data, compute the average temperature and assign it to a variable named avg_temp. Besides temps and avg_temp, you may use two other variables -- kand total.

4. A list named parking_tickets has been defined to be the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the list contains the number of tickets given on January 1; the last element contains the number of tickets given today.) Write some code that associates most_tickets with the largest value found in parking_tickets. You may, if you wish, use one additional variable, k.

5. Associate the sum of the non-negative values in the list numbers with the variable sum.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions