Question

Python What is the sum of the numbers from 1 to 10 (by one) multiplied by...

Python

What is the sum of the numbers from 1 to 10 (by one) multiplied by the numbers from 11 to 30 (incrementing by two) respectively? (Hint: create two arrays and use the function numpy.dot to multiply them)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::

import numpy
A=[]
B=[]
for i in range(1,11):
A.append(i)

for i in range(12,31,2):
B.append(i)

print("Array A is : ",A)
print("Array B is : ",B)
C = numpy.dot(A, B);
print("Result of dot product is : ",C)

output:

Add a comment
Know the answer?
Add Answer to:
Python What is the sum of the numbers from 1 to 10 (by one) multiplied by...
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
  • The following are short Python calculations. Give the answer and the Python code for each. 1....

    The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...

  • 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.

  • 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,...

  • Script 1: Sum of Numbers Write a python program that asks the user to enter a...

    Script 1: Sum of Numbers Write a python program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.

  • Exercise 1 - Create a List to Sum Values Write a python script that sums the...

    Exercise 1 - Create a List to Sum Values Write a python script that sums the values in a list called add_list that contains the following values: (10, 2, -4, 8). Make sure you include a for loop when iterating through the list to sum the values. Take screenshots of the code and output. Exercise 2 – Create a Dictionary Write a python script that prints a dictionary where the key numbers are 1, 2, 3, 4, and 5 and...

  • 1. Write a Python function that implements the following algorithm that computes the sum of the...

    1. Write a Python function that implements the following algorithm that computes the sum of the first n non-negative powers of 2: 20 + 21 + ... + 2n-1, where n ≥ 0: 1. Input n (assume n ≥ 0) 2. Set sum to 1 3. Set value to 2 4. Do the following n-1 times:    a. Add value to sum    b. Multiply value by 2 5. Output sum 2.Use turtle to draw two flags of two countries...

  • use python: Write a program that reads in X whole numbers and outputs (1) the sum...

    use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...

  • 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...

  • What two nonnegative real numbers with a sum of 30 have the largest possible product? Let...

    What two nonnegative real numbers with a sum of 30 have the largest possible product? Let x be one of the numbers and let P be the product of the two numbers. Write the objective function in terms of x. P= (Type an expression.) The interval of interest of the objective function is (Simplify your answer. Type your answer in interval notation) The numbers that have a sum of 30 and have the largest possible product are (Use a comma...

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