Answer to Question #293764 in Python for Jaber123456

Question #293764

b.

c. d.


1 2 3 4 5 6 7 8 9 10 11

Fill the array with random numbers between 10 and 90 Calculate and print out the sum of the elements in such manner:

- If the element is even divided by 2

- If the element is odd multiply it with 2

Display the array elements in reverse order 4 numbers on each line Create another array B of 12 integer numbers

Then copy the elements of A to B in such manner:

Write the odd numbers first then the even ones

A

 13

  25

  75

  35

  79

  50

  60

  90

  80

  40

  10

  90


1
Expert's answer
2022-02-05T02:03:41-0500


def find_pair_of_sum(arr: list, n: int):
	map = {}

	for i in range(n):
		for j in range(i+1, n):
			sum = arr[i] + arr[j]

			if sum in map:
				print(f"{map[sum]} and ({arr[i]}, {arr[j]})")
				return
			else:
				map[sum] = (arr[i], arr[j])

if __name__ == "__main__":
	arr = [3, 4, 7, 1, 2, 9, 8]
	n = len(arr)
	find_pair_of_sum(arr, n)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS