Question

Python Language ONLY! Python Language ONLY! Python Language ONLY! When doing this try to use a...

Python Language ONLY!

Python Language ONLY!

Python Language ONLY!

When doing this try to use a level one skill python, like as if you just learned this don't use anything advanced if you can please.

Write a for loop (only one for loop) that computes the total of the following series of numbers: (20/1)+(19/2)+(18/3)+(17/4)+.....+(1/20)

Homework Answers

Answer #1

total = 0  # set 0 to total

for i in range(1, 21):  # this loop will iterate i values from 1 to 20
    # 21-i values are 20, 19, 18, ..., 2, 1
    # i values are 1, 2, 3, ..., 20
    total += (21 - i) / i  # this will add 20/1, 19/2, ..., 1/20 to total

print(total)  # finally print the total


Know the answer?
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
Similar Questions
Try doing a task 3 different ways: a. Use an interactive Python session (shell) to print...
Try doing a task 3 different ways: a. Use an interactive Python session (shell) to print out a line of 5 stars 10 times (so there will be 10 lines of output, each line containing 5 stars) b. Write a function that does the same thing as above, having each line printed individually (you can do this either in the shell or in a module; either way, just copy and paste your code when submitting)
use python Write a program that uses a for loop to display all prime numbers within...
use python Write a program that uses a for loop to display all prime numbers within the range [500, 800] (hint: prime numbers are numbers that have only 2 factors: 1 and themselves. You can use a loop function to check if a number has a factor other than 1 or itself using % operation)
1) In Python Use a while loop to ask the user to enter a series of...
1) In Python Use a while loop to ask the user to enter a series of alphabets. The loop terminates when the user presses enter. Once the loop terminates, display the number of vowels and consonants entered by the user. Hint: keep a running count of the number of characters entered by the user. Keep a running count of the number of vowels. Total number of consonants = total number of characters - total number of vowels. Assume that the...
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...
USE ONLY C LANGUAGE The program should read inputs that look like this: 10 11 56...
USE ONLY C LANGUAGE The program should read inputs that look like this: 10 11 56 92 10 5 42 7 1 33 99 The program should start by reading one integer, which indicates how many numbers there are in the random sequence. The program should then read a sequence of random integers. If fewer numbers are provided than specified (by the first integer on the first line), the program should print the following error message (replace XXX with the...
Using python language 1- Write a function for checking the speed of drivers with 3 different...
Using python language 1- Write a function for checking the speed of drivers with 3 different speeds: 55, 90, 160. If the return result is 0, it should print “Good”. If the return is not zero but less then 12, it should print: ‘Too fast“ if the return is  greater than 70, then print “Your license is suspended!” 2- Write a function that takes a series of numbers as parameters to check if the driver is speeding up or slowing down....
Write a program in python that prints the count of all prime numbers between A and...
Write a program in python that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = The 5 digit unique number you had picked at the beginning of the semester B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2,...
a. Koko the gorilla was trained by Francine Patterson to use sign language. The Gorilla language...
a. Koko the gorilla was trained by Francine Patterson to use sign language. The Gorilla language Project reports that Koko can use 1000 different signs, and can understand 2000 words. Koko is now creating statements by blending three to six words. Choose the highest level that the animal may have attained and explain why you chose your choice. Select one: a. Phonology b. Morphology c. Syntax d. Semantics b. Nim Chimpsky (chimpanzee) was trained by Herbert Terrance to understand sign...
15. [2pt] Which star is brighter as seen from the Earth? (you only have one try...
15. [2pt] Which star is brighter as seen from the Earth? (you only have one try for this problem) A) A star with apparent magnitude 6 B) A star with apparent magnitude 15 16. [3pt] How many times brighter is it? Answer: 17. [2pt] Which star is more luminous? (you only have one try for this problem) A) A star with absolute magnitude 12 B) A star with absolute magnitude -1 Answer:   18. [3pt] How many times more luminous is...
Part II - Pi Calculation implementation. If you watch the Discovery or Sci-Fi channel you will...
Part II - Pi Calculation implementation. If you watch the Discovery or Sci-Fi channel you will find dozens of alien conspiracy shows that reference Pi as something so advanced that it must be alien.  The number πis a mathematical constant, the ratio of a circle's circumference to its diameter, commonly approximated as 3.14159. So you could graph the value or calculate an approximate value using the series given below: Pi = 4 * (1/1 – 1/3 + 1/5 – 1/7 +...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT