Python Assignment Myprogramminglab

Posted Under: Jupyter Lab / Hub

Ask A Question
Viewed 19

thirteen easy to solve Python problems to be answered in MyProgrammingLab by the end of TONIGT 

I attached the questions. You can have login of MyProgrammingLab to safe some time. 

1. Use two variables k and total to write a for loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. Thus, your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables other than k and total. 2. Given a variable n refers to a positive int value, use two additional variables, k and total to write a for loop to compute the sum of the cubes of the first n counting numbers, and store this value in total. Thus your code should put 1*1*1 + 2*2*2 + 3*3*3 +... + n*n*n into total. Use no variables other than n, k, and total. 3. Associate the average of the numbers from 1 to n (where n is a positive integer value) with the variable avg. 4. Assume there is a variable, h already associated with a positive integer value. Write the code necessary to compute the sum of the first h perfect squares, starting with 1. (A perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) Associate the sum you compute with the variable q. For example, if h is 4, you would assign 30 to q because the first 4 perfect squares (starting with 1) are: 1, 4, 9, 16 and 30==1+4+9+16. 5. An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if 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. 6. Given the positive integer distance and the positive integer n, associate the variable sum with the sum of the elements of the arithmetic progression from 1 to n with distance distance. For example, if distance is 2 and n is 10, then sum would be associated with 25 because 1+3+5+7+9 = 25. 7. Given a positive integer n, assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.) Instructor Notes: if an integer is divisible any integer smller than itself (other than 1) you can immediately set is_prime to False and break the loop · Given a variable bridge_players, write a statement that increases its value by 4. · Given a variable profits, write a statement that increases its value by a factor of 10. · Write a statement that increments total by the value associated with amount. That is, add the value associated with amount to that associated with total and assign the result to total. · n mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all the nonnegative integers from 1 to n. For example: 7! = 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5,040 Write a program that lets the user enter a nonnegative integer and then uses a loop to calculate the factorial of that number. Print the factorial to standard output.
Explanations and Answers 0

No answers posted

Post your Answer - free or at a fee

Login to your tutor account to post an answer

Posting a free answer earns you +20 points.


NB: Post a homework question for free and get answers - free or paid homework help.

Get answers to: Python Assignment Myprogramminglab or similar questions only at Tutlance.

Related Questions