Computers and Technology

1| my2DTuple = ((1, 2, 3), 2| (4, 5, 6), 3| (7, 8, 9)) 4| 5| sum = 0 6| for aTuple in my2DTuple: 7| for num in aTuple: 8| sum += num 9| print(sum) The code above adds up every integer in the 2D tuple my2DTuple. The goal is for it to print sum once at the end, once all the numbers have been added. Right now, however, it's printing sum after each individual number is added. sum is calculated correctly, but it is printed at every step along the way. How would we change this code so that sum prints only once, after all the numbers have been added? Select all the changes we would need to make.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:30, jayjay5246
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
Answers: 1
image
Computers and Technology, 25.06.2019 10:50, kkruvc
Which of the following is true of heuristics? a)heuristics always lead to correct solutions of a problem. b)heuristics represent commonly used approaches to the solution of a problem. c) heuristics are a slower way to solve problems than are other strategies. d)heuristics are used by computers but not by humans as problem-solving tools.
Answers: 3
image
Computers and Technology, 25.06.2019 16:30, millerbe1228
How many times do you usually use npm? put your answer in the box.
Answers: 1
image
Computers and Technology, 25.06.2019 17:20, lifewkeya
Athird of the sum of a number and ten is thirty
Answers: 1
Do you know the correct answer?
1| my2DTuple = ((1, 2, 3), 2| (4, 5, 6), 3| (7, 8, 9)) 4| 5| sum = 0 6| for aTuple in my2DTuple: 7|...

Questions in other subjects:

Konu
History, 14.11.2020 14:00
Konu
Mathematics, 14.11.2020 14:00
Konu
Chemistry, 14.11.2020 14:00