Computer Science, asked by khatrimoin, 8 months ago

write a python script to create a dictionary with class and name of subject teacher and delete a particular class and teacher name​

Answers

Answered by Anonymous
1

We have already seen how we can use a dictionary to group related data

When we create an object of that data type, we call it an instance of a class. .We use the same names for the attributes and the parameters, but this is not Defining a class also doesn't make anything run – it just tells Python about the class

Answered by leemashah666
1

Answer:

syntax:dict = { key1:value1, key2:value2,...keyN:valueN }

>>> capitals={"USA":"Washington, D.C.", "France":"Paris", "India":"New Delhi"}

Python - For Loop

else Loop

break

continue

pass

Python - range()

Python - Function

Lambda Function

Python - Variable Scope

Python - Module

Module Attributes

Python - Built-in Modules

OS Module

Sys Module

Math Module

Statistics Module

Collections Module

Random Module

Python - Packages

Python - Iterator

Python - Generator

Python - Map Function

Python - Filter Function

Python - Reduce Function

Python - List Comprehension

Python - Recursion

Python - Errors

Python - Exception Handling

Python - Assert

Python - Class

private and protected

property() function

@property Decorator

@classmethod Decorator

@staticmethod Decorator

Inheritance

Python - Magic Methods

Python - Database CRUD

Python - File I/O

Python - Tkinter UI

Python - Course & Books

Python - Dictionary

Like the list and the tuple, dictionary is also a collection type. However, it is not an ordered sequence, and it contains key-value pairs. One or more key:value pairs separated by commas are put inside curly brackets to form a dictionary object.

Syntax:

dict = { key1:value1, key2:value2,...keyN:valueN }

The following declares a dictionary object.

>>> capitals={"USA":"Washington, D.C.", "France":"Paris", "India":"New Delhi"}

In the above example, capitals is a dictionary object. The left side of : is a key and right side of : is a value. The key should be an immutable object. A number, string or tuple can be used as key. Hence, the following definitions of dictionary are also valid:

>>> numNames={1:"One", 2: "Two", 3:"Three"}

>>> decNames={1.5:"One and Half", 2.5: "Two and Half", 3.5:"Three and Half"}

>>> items={("Parker","Reynolds","Camlin"):"pen",("LG","Whirlpool","Samsung"): "Refrigerator"}

However, a dictionary with a list as a key is not valid, as the list is mutable:

>>>dict={["Mango","Banana"]:"Fruit", ["Blue", "Red"]:"Colour"}

TypeError: unhashable type: 'list'

But, a list can be used as a value.

>>>dict={"Fruit":["Mango","Banana"], "Colour":["Blue", "Red"]}

The same key cannot appear more than once in a collection. If the key appears more than once, only the last will be retained. The value can be of any data type. One value can be assigned to more than one key.

>>>staff={"Krishna":"Officer", "Steve":"Manager", "John":"officer", "Anil":"Clerk", "John":"Manager"}

>>>staff

{"Krishna":"Officer", "Steve":"Manager", "Anil":"Clerk", "John":"Manager"}

Explanation:

Similar questions