Question: PYTHON CODES 1) Use two variables k and total to write a for loop to compute the sum of the squares of the first 50
PYTHON CODES
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) Write a complete program that reads 6 numbers and assigns True to variable isAscending if the numbers are in ascending order. Otherwise assign False to it. Display the value of isAscending. Here are three sample runs:
Sample Run 1
Enter six numbers: 4 6 8 10 11 12 True
Sample Run 2
Enter six numbers: 4 6 3 10 11 12 False
Sample Run 3
Enter six numbers: 41 6 3 10 11 12 False
Note: Your program must match the sample run exactly.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
