Question

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 the values are the key number times 2. Be sure to use an appropriate loop to iterate through the dictionary when printing the dictionary.

Take screenshots of the code and its output where specified and paste them into a well-labeled Word document for submission.

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

Excersise 1:

#Main

add_list =[10, 2, -4, 8]

sum=0

for i in add_list:

sum+=i

print("sum of values in add_list: ",sum)

################################

#Output

sum of values in add_list: 16

//Screen shot

Excersise 2:

myDict={1:2,2:4,3:6,4:8,5:10}

for key in myDict:

print("key: ",key)

print("value: ",myDict[key])

=====================

#Output

key: 1
value: 2
key: 2
value: 4
key: 3
value: 6
key: 4
value: 8
key: 5
value: 10

//Screen shot

Add a comment
Know the answer?
Add Answer to:
Exercise 1 - Create a List to Sum Values Write a python script that sums the...
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
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
ADVERTISEMENT