Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the list below has some words: my_list = ['orchids','chamber','phoenix','central','juggler','dungeon','passive', 'capable','creator','rabbits','succeed','compute','achieve','attempt', 'network','address','supreme','believe','concern','explore','finance', 'benifit','license','carcass','abalone','morning','abandon','macabre', 'teacher','billion','yankees','mistake','suspect','barrack','connect', 'operate','cabbage','ability','rushing','passion','perfect','fashion', 'outputs','success','banking','journal'] # the following creates an empty dictionary my_dict =

the list below has some words:
my_list = \
['orchids','chamber','phoenix','central','juggler','dungeon','passive',
'capable','creator','rabbits','succeed','compute','achieve','attempt',
'network','address','supreme','believe','concern','explore','finance',
'benifit','license','carcass','abalone','morning','abandon','macabre',
'teacher','billion','yankees','mistake','suspect','barrack','connect',
'operate','cabbage','ability','rushing','passion','perfect','fashion',
'outputs','success','banking','journal']
# the following creates an empty dictionary
my_dict = dict()
# a) Write python code below that does the following:
# iterate over the words in my_list and for each item add a key-value
# pair in my_dict such that: the key is the item (word) and the value is
# the number of vowels (a,e,i,o,u) in that word with one exception --
# if that word is CHAMBER then the value should be 12345
# As an example, if my word is orchids, and my number is 10233, then
# here are a sample of 3 key-value pairs in my_dict:
# 'orchids': 10233, 'chamber': 2, 'phoneix': 3...
# NOTE: do not add the key-value pairs manually. You must write code
# using a loop that iterates over the words in my_list and figures out the
# number of vowels in code-logic. If you do not have any logic that determines
# number of vowels -- you will not get any points to this question (you will
# get points for the next question, if that is done correctly)
# b) Write python code below that does the following:
# iterates over the my_dict and computes the sum of all the values and
# puts the result in my_sum. my_sum has been initialized to 0.
my_sum = 0
###############################################################################
# please do not modify these last few lines. They will be used to evaluate your
# exam. If you have used any print statements in your own code, please comment
# them out.
print(f'Q3:my_dict:{len(my_dict)}:{my_dict}')
print(f'Q3:my_sum:{my_sum}')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago