Subscribe this Blog

Wikipedia

Search results

Notifications and New Posts!

Saturday, October 3, 2020

Google Meet Session - 3rd Oct. September 2020 ADVANCED PROGRAMMING CONCEPTS - Python (TY A and B)

 ADVANCED PROGRAMMING CONCEPTS - Python

Saturday, 3 October16:00 – 17:00
Weekly on Saturday, until 30 Nov 2020
Join with Google Meet
https://meet.google.com/fza-dxad-utd
Description: Subject : ADVANCED PROGRAMMING CONCEPTS - Python To solve assignments Please join Google Classroom. Invitation of Google Classroom has been sent to your official email id. Please accept the google classroom invitation through official email id. Or directly by entering Class code of Google Classroom also you can join Google Class room to solve assignments. Class code of Google Classroom : 3ojdsjm With kind regards, SD Bhosale
  1. 5 minutes before
Organiser: Sachin Bhosale

To know attendance : Click here
MCQ Discussion:
Which statement correctly assigns the string "Rahul" to the variable name?
a) name  = print( "Rahul")
b) input("Rahul")
c) name = "Rahul"
d) name = input("Rahul")

Ans: c)

Explanation:
name  = print("Rahul")
print("check",name)

name = input("Rahul")
print("asflksdjflkdjflkdsjflkdj check none none",name)

name = "Rahul"
print("check",name)


Output:
Rahul
check None
Rahul
asflksdjflkdjflkdsjflkdj check none none 
check Rahul

Thank you to Onkar Kale to bring and ask this MCQ. 
Thank you to Mr. Jaydev for giving some explanation regarding this MCQ.
Because of him, I could able to understand.

Today's Programs:
# Accessing Items
# You can access the items of a dictionary by referring to its key name,
# inside square brackets:
# Example
# Get the value of the "model" key:

thisdict = {
  "brand": "Maruti",
  "model": "k10",
  "cc": 1000,
  2:20,
  1.5:"TYMECH"
}

x = thisdict[1.5]
print(x)
print(type(x))

y=thisdict["brand"]
print(y)
Output:
TYMECH
<class 'str'>
Maruti

# There is also a method called get() that will give you the same result:
# Example
# Get the value of the "model" key:

thisdict = {
  "brand": "Maruti",
  "model": "k10",
  "cc": 1000
}
x = thisdict.get("model")
print(x)
Output:
k10

# Change Values
# You can change the value of a specific item by referring to its key name:
# Example
# Change the cc to 1000:


thisdict = {
  "brand": "Maruti",
  "model": "k10",
  "cc": 800
}

print(thisdict)

thisdict["cc"] = 1000

print(thisdict["cc"])
print(thisdict)
Output:
{'brand': 'Maruti', 'model': 'k10', 'cc': 800}
1000
{'brand': 'Maruti', 'model': 'k10', 'cc': 1000}

# Loop Through a Dictionary
# You can loop through a dictionary by using a for loop.
# When looping through a dictionary,
# the return value are the keys of the dictionary,
# but there are methods to return the values as well.
# Example
# Print all key names in the dictionary, one by one:

thisdict = {
  "brand": "Maruti",
  "model": "k10",
  "cc": 1000
}

print("Displays Keys:")
for x in thisdict:
  print(x)

print("Displays Values:")
for y in thisdict:
  print(thisdict[y])
Output:
Displays Keys:
brand
model
cc
Displays Values:
Maruti
k10
1000

# Example
# Print all values in the dictionary with keys, one by one:

thisdict = {
  "brand": "Maruti",
  "model": "k10",
  "cc": 1000
}

for x in thisdict:
  print(x,":",thisdict[x])

Output:
brand : Maruti
model : k10
cc : 1000


Recorded Google Meet Session: 


YouTube Channel.

Just your one like enhances my energy to engage next lecture!
<! -- The End -->

No comments:

Post a Comment