Question: Working with Dictionaries a) Convert the below given values into a dictionary in a way that the course codes and the course names are for
Working with Dictionaries
a)Convert the below given values into a dictionary in a way that the course codes and the course names are for the keys and the values. Use the update () method and print the result.
COMP100 PROGRAMMING 1
COMP228 JAVA PROGRAMMING
COMP237 INTRO. TO AI
COMP246 SOFTWARE SYSTEMS DESIGN
COMP257 UNSUPERVISED LEARNING
COMP258 NEURAL NETWORKS COMP387 IT SOLUTIONS
b)Check if the value neural networks exists in the dictionary, and print the result.
c)Use the get () method to retrieve the name of key COMP237, result to be shown.
d)Delete the keys COMP387 and COMP246, print the dictionary to show the result.
e)Sort the dictionary by values in ascending order and display the result.
Working with Strings
1.Apply the positive and negative indexing to the string named as course. Print and show. Course = "Python"
2.Print the course name, character by character using for loop
3.A string having immutable nature. Once we create a string object then we cannot change or modify the existing object. Show that by using the above course by change P to R
4.Make use of the methods upper (), lower (), swapcase (), title (), capitalize () to change the cases of the given string in Python. String = centennial college courses Give your own examples to perform two mathematical operators (+ and *) on a string.
Working with Functions
1.Actual and formal arguments are important part of a program. The difference Between Actual and Formal Parameters is that the actual parameter is used to invoke the information while executing the program, but the formal parameters are declared while calling the function. Show the use of formal and actual arguments by taking x, y and z. Pass the values 55, 77 and 88 to print it on the screen.
2.Print the id = 77898, qualification = PhD and name = Grace, by using the keyword variable length argument (**variable) in python.
3.Show the use of default arguments in python. The function shop has parameters as items and price. Lets say the price of many items is $5 by default. In this case, we can set the price parameter to the default value of $5. Though, Price has a default value of 5. Still, if we provide the values at the time of calling then the default values will be overridden with the passed values.
4.Create a function by name shop with the keywords item, amount. Assign the amounts to the corresponding items, say purse = $35, bag = $70. Print the items pen, purse, bag and their amount.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
