Question

Write Python expressions corresponding to the following statements: The sum of the first five positive integers...

  1. Write Python expressions corresponding to the following statements:
  1. The sum of the first five positive integers
  2. The average age of Sara (age 23), Mark (age 19), and Fatima (age 31)
  3. The number of times 73 goes into 403
  4. The remainder when 403 is divided by 73
  5. 2 to the 10th power
  6. The absolute value of the difference between Sara’s height (54 inches) and Mark’s height (57 inches)
  7. The lowest price among the following prices: $34.99, $29.95, and $3

Homework Answers

Answer #1

Answers:

a) The sum of the first five positive integers

The Answer is (1+2+3+4+5) (or) sum(range(1,6))

Explanation: range() function gives the values from starting value to (n-1). (In our example, it starts at 1 and produces the numbers up to 5)

sum() function sums up the values generated by range() function. (In our example, it is 1,2,3,4,5)

b) The average age of Sara (age 23), Mark (age 19), and Fatima (age 31)

We can find the average by summing up all the numbers, and divide it by number of numbers summed up.

For our example, The Answer is (23+19+31) / 3

c) The number of times 73 goes into 403

We can find the number of times 73 goes into 403, by dividing 403 by 73.

The Answer is 403/73 (or) 403//73 ('/' operator gives fraction where as '//' gives an integer)

d) The remainder when 403 is divided by 73

The operator for finding remainder is %

The Answer is 403 % 73

e) 2 to the 10th power

To calculate the exponent, we use the operator **

The Answer is 2**10

f) The absolute value of the difference between Sara’s height (54 inches) and Mark’s height (57 inches)

The absolute value is calculated by using abs() function. (Absolute value is a positive value)

The Answer is abs(54-57)

g) The lowest price among the following prices: $34.99, $29.95, and $3

Minimum value is calculated by using min() function.

The Answer is min(34.99,29.95,3)

Output Screenshot after executing all the above expressions

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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • 7. How have angiosperms coevolve with pollinators to enhance the fitness of both partners? Consider factors...
    asked 8 minutes ago
  • If the effect size for a four-group study was .5, the sum of square between was...
    asked 21 minutes ago
  • What technology out there do you find the most exciting and interesting currently? Why?  What interests you...
    asked 27 minutes ago
  • 5. Classify each description as observational or experimental (a)Participants in a study to determine the effects...
    asked 30 minutes ago
  • Python Write function stringCount() that takes two string inputs—a file name and a target string— and...
    asked 31 minutes ago
  • If you pay more in tuition to go to a top business​school, will it necessarily result...
    asked 36 minutes ago
  • Choosing manual vs automated testing comes down to benefits gained on your particular project. In this...
    asked 38 minutes ago
  • In banker's algorithm, which process will be handle first? process   need (A, B) p1            1, 4...
    asked 49 minutes ago
  • Assignment 3 Chapter 2: Algorithm Discovery and Design More about Pseudocode Design an algorithm that is...
    asked 51 minutes ago
  • Justify answer. Is the Jaccard coefficient for two binary strings (i.e., string of 0s and 1s)...
    asked 53 minutes ago
  • Solve the following system of equations and determine if there is a unique solution, an infinite...
    asked 1 hour ago
  • In C++ ------------------------------------------ All functions take no parameters as input and return nothing. Create a function...
    asked 1 hour ago