Question
in PYTHON!
Define a function count() that compute and returns the sum of the first 100 even numbers.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hem ON 1. def count(): sum = 0 for number in range(1,101): if(number % 2 == 0): sum+=number; return sum 8 print(sum of first

def count():

sum = 0

for number in range(1,101):

if(number % 2 == 0):

sum+=number;

return sum

print("sum of first 100 even numbers is: ", count())

Add a comment
Know the answer?
Add Answer to:
in PYTHON! Define a function count() that compute and returns the sum of the first 100...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Define a function in python that returns the sum of the following 4 lists. Remember...

    1. Define a function in python that returns the sum of the following 4 lists. Remember to store and re- use your code instead of summing the values for each list 4 times. Hence, define a function that takes as an argument a list and returns the sum of values. Copy the following lists and paste them in a Python file after you define the sum_of_values function Call the function and pass to it a different list each call as...

  • Define a python function even(string) that accepts a python string of any length and returns a...

    Define a python function even(string) that accepts a python string of any length and returns a new string made of just the characters with even indexes For example even('Final exam') should return a string 'Fnlea'.

  • Define a Python function that takes a list and returns the length of the list using...

    Define a Python function that takes a list and returns the length of the list using map and sum.

  • In Python 3 Write code to define a function that uses three arguments, and returns a...

    In Python 3 Write code to define a function that uses three arguments, and returns a result. The function returns True if the first argument is more than or equal to the second argument and less than or equal to the third argument, otherwise it returns False.

  • PYTHON The function longest that returns the longest of two strings. The function count_over that takes...

    PYTHON The function longest that returns the longest of two strings. The function count_over that takes a list of numbers and an integer nand returns the count of the numbers that are over n. The function bmi that takes two parameters height and weight and returns the value of the body mass index: a person's weight in kg divided by the square of their height in meters. def longest(string1, string2): """Return the longest string from the two arguments, if the...

  • Write a Python program (special_sum.py) that calculate a special sum of 4 numbers, all int. The...

    Write a Python program (special_sum.py) that calculate a special sum of 4 numbers, all int. The rule for this special sum is as follow: If one of the entered numbers is 17, then it does not count towards the sum and the numbers entered after it do not count. For full credit, you must use function. Your function should have 4 int as parameters, and returns the special sum (as an int). Call this function specialsum and use main program:...

  • ****python**** Q1. Write a recursive function that returns the sum of all numbers up to and...

    ****python**** Q1. Write a recursive function that returns the sum of all numbers up to and including the given value. This function has to be recursive; you may not use loops! For example: Test Result print('%d : %d' % (5, sum_up_to(5))) 5 : 15 Q2, Write a recursive function that counts the number of odd integers in a given list. This function has to be recursive; you may not use loops! For example: Test Result print('%s : %d' % ([2,...

  • Python problem: Create a function (fun1) that adds two numbers together and returns the sum. Create...

    Python problem: Create a function (fun1) that adds two numbers together and returns the sum. Create another function (fun2) that uses that calls fun1, passing it two parameters, and prints your name the number of times that is returned from fun1 (so, if my fun1 returned the number 3, then I would see my name printed 3 times). Call fun2.

  • Define a Python function named getResponse() that takes a string as its only argument and returns...

    Define a Python function named getResponse() that takes a string as its only argument and returns a new string. If the argument ends with a question mark and has an even number of characters, the function should return the string "Yes". If the argument ends with a question mark and contains an odd number of characters, the function should return the string "No". If the argument ends with an exclamation point, the function should return the string "Wow". Otherwise, the...

  • in Python, define a function named filterOut with three parameters. The first argument passed to the...

    in Python, define a function named filterOut with three parameters. The first argument passed to the function should be a list of dictionaries (the data), the second a string (a dictionary key), and the third another string (a dictionary value). This function must return a list of all the dictionaries from the input list which do NOT contain the indicated key:value pairing. in Python, define a function named filterInRange with four parameters. The first argument passed to the function should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT