Question

Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate...

Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate the key 'class_name' with the value 'MAT123', and associate the key 'sect_num' with '211_145' PYTHON

Homework Answers

Answer #1

Python code:

#creating a dictionary called called Class
Class={}
#adding to it key class_name and value MAT123
Class["class_name"]="MAT123"
#adding to it key sect_num and value 211_145
Class["sect_num"]="211_145"
#printing the Class dictionary
print(Class)


Screenshot:


Output:

Know the answer?
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
Similar Questions
Write a Python program to create a dictionary from two lists without losing duplicate values. If...
Write a Python program to create a dictionary from two lists without losing duplicate values. If there is more values in the key list, then provided key should return an empty set if there is no match. (Hint: use defaultdict) Example: class_list = ['Class-V', 'Class-VI', 'Class-VII', 'Class-VIII','Class-IX'] id_list = [1, 2, 2, 3] Output: assuming you store the values in a data structure named temp print(temp["Class-V"]) # {1} print(temp["Class-IX"]) # set() can you please try and do on google colab
8) Write Python code for a function called occurances that takes two arguments str1 and str2,...
8) Write Python code for a function called occurances that takes two arguments str1 and str2, assumed to be strings, and returns a dictionary where the keys are the characters in str2. For each character key, the value associated with that key must be either the string ‘‘none’’, ‘‘once’’, or ‘‘more than once’’, depending on how many times that character occurs in str1. In other words, the function roughly keeps track of how many times each character in str1 occurs...
Python Write the contents of the function below. It should build a dictionary with keys and...
Python Write the contents of the function below. It should build a dictionary with keys and values. For each such entry, it must enter two rows from the keyboard. The first line should constitute the key to be stored in a form with only capital letters. The user enters the value on the next row. This should be stored as an integer. If you enter a blank line as the key, the lock should end and the dictionary is returned....
On python a) Create a dictionary with 5 to 10 key-values so that state is the...
On python a) Create a dictionary with 5 to 10 key-values so that state is the key and its capital is the value. Print the dictionary and its length. b) Create and print a list of states and a list of capitals. c) Ask the user for a state's name. Check to see if the state's name exists in the list of states. If it does, look up the state's name in the dictionary and print out its capital. If...
write code using python or repl.it 1. List 4 attributes that you'd create for class "student"....
write code using python or repl.it 1. List 4 attributes that you'd create for class "student". 2. List 2 setters and 2 getters for class student including their parameters 3. Write the complete definition for class student including attributes and methods created above using the correct Python syntax. 4. Create one object of class student and print the values of all its attributes. You can either call the getter method or access the attribute directly using the dot notation.
Write Python code to define a class called Student. The Student class should have the following...
Write Python code to define a class called Student. The Student class should have the following private fields: name – to store the name of a student attend – to store how many times a student attend the class grades – a list of all student’s grades The Student class should have the following methods: a constructor getter method for the name field attendClass method: that increments the attend field (should be called every time a student attends the class)....
Write code that maps Strings to the Integers which represent the lengths of the Strings. Create...
Write code that maps Strings to the Integers which represent the lengths of the Strings. Create a class with a Map <String, Integer>. Write one method called addStringToMap() that takes a String parameter and adds an entry to the Map with the String as the key and the length of the String as the value. Note that, if there is already an entry with that String as the key, nothing will happen when you add the entry. Write a method...
THE CODE MUST BE PYTHON # create a file with the name <last_three_digits_of_your_empl_id>.txt # write into...
THE CODE MUST BE PYTHON # create a file with the name <last_three_digits_of_your_empl_id>.txt # write into this file two lines: # 1. your name # 2. your hobby # close this files. # # open the created files <last_three_digits_of_your_empl_id>.txt, # add a third line to this file with today's date. # close the file.
In pseudo code (or python) create a loop that will ask the use to enter and...
In pseudo code (or python) create a loop that will ask the use to enter and then add five zip codes to a one-dimensional array called zip code and then read and display that zip code array to the screen.
12) Using the code in question 8: Write the python statement which will remove both the...
12) Using the code in question 8: Write the python statement which will remove both the key ‘gpa’ and its value 2.8 from s2 13) True or False? A dictionary is a set of items; each item consists of a colon-separated key and value. Each item is separated from other items using a comma. Dictionaries may contain both simple and complex data types. A dictionary may contain data about a single object. Another dictionary may contain data about multiple objects....