January 2023 Evening

DOWNLOAD LINKS

Python:  https://learn.swapnil.pw/python/pythoninstallation

 

 Pycharm:  https://learn.swapnil.pw/python/pythonides

 

 R & RStudio:   https://swapnil.pw/uncategorized/installating-r-studio

 

Domain Knowledge: https://www.mckinsey.com/featured-insights

 

Refer handnotes on Android Phone: Story mantra app

https://play.google.com/store/apps/details?id=com.hachiweb.story_mantra&hl=en_IN&gl=US

#interpreter: Python R
print("Hello")
print(5+4)
print('5+4=',5+4,'so what even 4+5=',4+5)
a=5 # variable
print("type of a in line #5 is ",type(a))
print("a = ",a)
#type of data (datatype) is integer - numbers without decimal point -99999,999
a = 5.0 #data type is float - numbers with decimal point, -999.5, 0.0, 99.9
print("type of a in line #9 is ",type(a))
a = 5j # i in Maths - square root of -1
print("type of a in line #11 is ",type(a))
#square root of -4 = 2i
print("a*a = ",a*a) #
a=9
print("a = ",a)
#function - print(), type()
# ,
#variable - constant
# is comment - Python these are not for you. these for us
a="HELLO" #text - in python type - string str
print("type of a in line #21 is ",type(a))

 

 

a = True #boolean = True or False
#print(type(a))
print(“type of a in line #24 is “,type(a))
#compiler: C. C++ Java

#Android – STORY MANTRA – after you login
#on the home page you will see- CATEGORIES -> Technical
#Technical -> Python, R ,

print("Hello")  #fist line
print('irte834t8ejviodjgiodfg0e8ruq34tuidfjgiodafjgodafbj')

 

print(5+3)
print(‘5+3’)
print(‘5+3=’,5+3,“and 6+4=”,6+4)
#whatever is given to print() shall be displayed on the screen
#syntax – rules (grammar)
#COMMENTS

DAY 1 VIDEO- Click to Access

#print(), type()
#comments
#data types: int, float, str,bool, complex
#variables - will accept alphabets, numbers and _
price = int(51.9876);
quantity = 23;
total_cost = price * quantity;
print(total_cost);
print("Given price is", price,"and quantity bought is",quantity,"so total cost will be",total_cost)

# f string
print(f"Given price is {price:.2f} and quantity bought is {quantity} so total cost will be {total_cost:.2f}")

player = "Sachin"
country = "India"
position = "Opener"
print(f"{player:<15} is a/an {position:>15} and plays for {country:^15} in international matches.")
player = "Mbwangebwe"
country = "Zimbabwe"
position = "Wicket-keeper"
print(f"{player:<15} is a/an {position:>15} and plays for {country:^15} in international matches.")

#Sachin is a/an Opener and plays for India in international matches.
#Mbwangebwe is a/an Wicket-keeper and plays for Zimbabwe in international matches.

#escape sequence \
print("abcdefghijklm\nopqrs\tuv\wx\y\z")
# \n - newline

# \n is used for newline in Python
print("\\n is used for newline in Python")

# \\n is actually give you \n in Python
print("\\\\n is actually give you \\n in Python")


# Data types - 5 main types
var1 = 5
print(type(var1)) # int - integer -9999 0 5

var1 = 5.0
print(type(var1)) #float - numbers with decimal

var1 = 5j
print(type(var1)) #complex - square root of minus 1

var1 = True #False #bool
print(type(var1))

var1 = "hello" #str - string
print(type(var1))

#input() - is used to read a value from the user
num1 = float(input("Enter a number: "))
print(f"{num1} is the number")
print("Datatype of num1 is ",type(num1))

var2 = "50"

#implicit and explicit conversion

# arithmetic Operations that can be performed on
# numeric (int, float, complex): i/p and o/p both are numbers
num1 = 23
num2 = 32 #assign 32 to num2
print(num1 + num2) #addition
print(num1 - num2) #
print(num1 * num2) #
print(num1 / num2) #
print(num1 // num2) #integer division: it will give you only the integer part
print(num1 ** num2) # Power
print(num1 % num2) # mod modulus - remainder

## comparison operator : input as numbers and output will be bool
## > < == (is it equal?) != , >= <=
num1 = 23
num2 = 32
num3 = 23
print(num2 > num3) # T
print(num3 > num1) # F
print(num2 >= num3) #T - is num2 greater than or equal to num3 ?
print(num3 >= num1) # T
print(num2 < num3) # F
print(num3 < num1) # F
print(num2 <= num3) # F
print(num3 <= num1) # T
print(num2 == num3) # F
print(num3 != num1) # F

# Logical operator: and or not
# prediction 1: Sachin or Saurav will open the batting - T
# prediction 2: Sachin and Saurav will open the batting - F
# actual: Sachin and Sehwag opened the batting

#Truth table - on boolean values
# AND Truth Table:
### T and T => T
### T and F => F
### F and T => F
### F and F => F

# OR Truth Table:
### T or T => T
### T or F => T
### F or T => T
### F or F => F

# NOT
## not True = False
## not False = True

## Assignment 1: Get lenght and breadth from the user and calculate
## area (l*b) and perimeter (2(l+b))

## Assignment 2: Get radius of a circle from the user and calculate
## area (pi r square) and curcumference (2 pi radius)
#Logical operator: works on bool and returns bool only
# and: all values have to be True to get the final result as True
# or: anyone value is True, you get the final result as True
# 5 * 99 * 7 * 151 * 45 * 0 = 0
# 0 + 0 + 0 + 0+1 = 1

print(True and True and False or True or True and True or False or False and True and True or False)
num1 = 5
num2 = 8
print(num1 !=num2 and num1>num2 or num1<=num2 and num2>=num1 or num1==num2 and num1<num2)

num3 = bin(18) #0b10010
print(num3)
print("hex(18) = ",hex(18)) #0x12
print("oct(18): ", oct(18)) #0o22

print("hex(0b1101111) = ",hex(0b1101111))
print("int(0b1101111) = ",int(0b1101111))

#BITWISE Operators
# left shift (<<) / right shift (>>) operators work on only binary numbers
print("56 << 3 = ",56 << 3) #output #111000000
print(bin(56))
print(int(0b111000000)) #448

print("56 >> 4 = ",56>>7) #

# & and in bitwise
print("23 & 12 = ",23 & 12) #4
print("23 | 12 = ",23 | 12) #31
print(bin(23)) #10111
print(bin(12)) #01100
#& 00100
print(int(0b100))
# | 11111
print(int(0b11111))

# | or in bitwise

num1 = 10
#positive
#negative

# area of a circle = pi * r**2 (3.14 = pi)
# circunference = 2 * pi * r

# Conditions
avg = 30
if avg >=40:
print("Pass") #indentation
print("Congratulations!")
else: #incase of IF getting False condition
print("You have failed")
print("try again")

#avg > 90 - Grade A
#avg 80 to 90 - Grade B
# avg 70 to 80 - Grade C
#avg 60 to 70 - Grade D
#avg 50 to 60 - Grade E
#avg 40 to 50 - Grade F
#avg <40 - Grade G

avg=30
if avg>=40:
print("Pass") # indentation
print("Congratulations!")

if avg>=90:
print("Grade A")
if avg >=95:
print("You win President Medal")

elif avg>=80:
print("Grade B")
elif avg >=70:
print("Grade C")
elif avg >=60:
print("Grade D")
elif avg >=50:
print("Grade E")
else:
print("Grade F")
else:
print("You have failed")
print("try again")
print("Grade G")


avg = 90
if avg <40:
print("Grade G")
elif avg <50:
print("Grade F")
elif avg <60:
print("Grade E")
elif avg <70:
print("Grade D")
elif avg <80:
print("Grade C")
elif avg <90:
print("Grade B")
else:
print("Grade A")

print("Thank you so much")

num = 5
if num > 0:
print("Number is positive")
if num % 2 == 1:
print("Its Odd")
else:
print("Its even")
if num % 3 == 0:
print("It is divisible by both 2 and 3. It is also divisible by 6")

else:
print("Its divisible by 2 but not 3")

elif num == 0:
print("Neither Positive not negative")
else:
print("Its Negative")

#loops - repeating multiple lines of code
#Python - 2 types of loops- one when you know how many times to repeat - FOR
#repeat until some condition true WHILE
# range(a,b,c) #generates range of values - start from a, go upto b(exlusive), c=increment
#range(2,6,2) = 2,4
#range(5,9) = (2 val indicate a&b - c is default 1) => 5,6,7,8
#range(5) = (its b, a is deafult 0 and c is default 1) = ?

for i in range(3,9,2):
print("HELLO",i)

for i in range(10):
print(i*2+2,end=", ")
print("\n")
for i in range(5):
print("*",end=" ")
print("\n=================")
'''
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
'''
for j in range(5):
for i in range(5):
print("*",end=" ")
print()

#for loop
for i in range(5):
print(i)
print()

for j in range(5):
for i in range(5):
print("*",end=" ")
print()

'''
*
* *
* * *
* * * *
* * * * *
'''
for j in range(5):
for i in range(j+1):
print("*", end=" ")
print()

'''
* * * * *
* * * *
* * *
* *
*
'''
for j in range(5):
for i in range(5-j):
print("*", end=" ")
print()

num,sum = 5,0
while num <103:
sum+=num
print(num)
num+=5

print("Sum = ",sum)
i=0
while True:
i=i+1
print("Hello, i is ",i)
ch=input("Enter y to stop: ")
if ch=='y':
break
print("One more hello")
if i%5==0:
continue
print("Another hello but not to print when its multiple of five")
a,b,c = 10,12,8
if a>=b:
#either a is greater or equal
if a>=c:
print(f"{a} is greatest value")
else:
print(f"{c} is greatest value")
else:
#b is greater
if b>=c:
print(f"{b} is greatest value")
else:
print(f"{c} is greatest value")
#Assignmnt : Modify the above program to display 3 number is descending order

#loops - repeating
#FOR - how many times
#range(a,b,c) - generates value from a upto b and increasing by c
#range(5,19,4) - 5, 9,13,17
#range(4,19,5) - 6,11,17
#WHILE - repeating based on condition

############################
#Strings
str1 = 'Hello how are you'
str2 = "Im fine"
str3 = '''How are you today
are you fine
hope you feel better'''
str4 = """I am fine today
expecting to do well
I am feeling better now"""
print(str3)

print(str1 + " "+str2)
print(str2*10)
print("Lo" in str1)

#indexing: slicing dicing
print(str1[0])
print(str1[4])
print(str2[-1])
print(str1[6:9])
print("->",str1[-11:-8])
print("First 3 values: ",str1[:3])
print("last 3 values: ",str1[-3:])

#
print(str1.upper())
#string immutable - you cant edit the string
#str1[0]="K" TypeError: 'str' object does not support item assignment
str1 = "K"+str1[1:]
print(str1)
str1 = "hello how are you?"
print("last 3 characters: ",str1[-3:])
for i in str1:
print(i)

print(str1.islower())
print(str1.isupper())
print(str1.isalpha()) #
str1 = "509058585855"
print(str1.isdigit())
print(str1.isspace())
str1 = "hello how are you?"
print(str1.title())
print(str1.lower())
print(str1.upper())

str2 = "I am fine how are you doing today"
target = "aeiou"
count=0
for i in str2:
if i.lower() in target:
count+=1
print("Total vowels: ",count)

result = str1.split()
print(result)
result2 = str1.split('ow')
print(result2)
result3 = "OW".join(result2)
print(result3)

print(str1.find('o',0,5))
print(str1.replace("hello","HELLO"))
print(str1)

#strings are immutable
var1 = 5 # integer
print(type(var1))
var1 = 5.0 # float
print(type(var1))
var1 = "5" # string
print(type(var1))
var1 = 5j # complex
print(type(var1))
var1 = True # bool
print(type(var1))

#Arithematic operations
num1 = 5
num2 = 3
print(num1 + num2)
print(num1 - num2)
print(num1 * num2)
print(num1 / num2)
print(num1 // num2) #integer division
print(num1 % num2) #modulo - remainder
print(num1 ** num2) # power

##Once I had been to the post-office to buy stamps of five rupees,
# two rupees and one rupee. I paid the clerk Rs. 20,
# and since he did not have change, he gave me three more
# stamps of one rupee. If the number of stamps of each type
# that I had ordered initially was more than one,
# what was the total number of stamps that I bought.
total = 30
stamp_5_count = 2 #>=
stamp_2_count = 2 #>=
stamp_1_count = 2+3 #>=
total_by_now = stamp_5_count * 5 + stamp_2_count * 2 + stamp_1_count * 1
print(total_by_now, "is total by now")
accounted_for = total - total_by_now

stamp_5_count = stamp_5_count + accounted_for //5
accounted_for = accounted_for %5

stamp_2_count = stamp_2_count + accounted_for //2
accounted_for = accounted_for %2

stamp_1_count = stamp_1_count + accounted_for

print("You will end up getting:")
print("Number of 5 Rs stamp = ",stamp_5_count)
print("Number of 2 Rs stamp = ",stamp_2_count)
print("Number of 1 Rs stamp = ",stamp_1_count)
total_value = stamp_5_count*5 + stamp_2_count* 2+ stamp_1_count*1
print("Net difference between amount and stamp value: ",total-total_value)

#Comparison operators: < > <= >= == !=
num1 = 7
num2 = 7
print("is num1 equal to num2? ", num1==num2) #== ??
print("is num1 not equal to num2?", num1!=num2)
print("is num1 greater than num2? ", num1>num2)
print("is num1 greater than or equal to num2?", num1>=num2)
print("is num1 less than num2? ", num1<num2)
print("is num1 less than or equal to num2?", num1<=num2)

#Logical operators: and (*) or (+) not
# pred: sachin and sehwag will open the batting
# actual: sachin and sourav opened the batting - wrong

# pred: sachin or sehwag will open the batting
# actual: sachin and sourav opened the batting - right

print(True and True) #True
print(True and False) #rest is all False
print(False and True)
print(False and False)

print(True or True) #True
print(True or False) #True
print(False or True) #True
print(False or False) #False

print(not True) #

num1 = 7
num2 = 7
print("=>",num1==num2 and num1!=num2 or num1>num2 or num1>=num2 and num1<num2 and num1<=num2)
# F
# conditional check
num1 = 100
#perform check - IF condition
if num1>0:
print("Its positive")
#We use conditions when we need to control the flow of the program
avg = 88

#avg: 90 to 100: A , 80-90: B, 70-80: C , 60-70: D
#50 to 60: E, 40 to 50: F, <40: Failed
# if ... elif.. else

if avg >=90:
print("Pass")
print("Grade A")
elif avg>=80:
print("Pass")
print("Grade : B")
elif avg>=70:
print("Pass")
print("Grade : C")
elif avg>=60:
print("Pass")
print("Grade : D")
elif avg>=50:
print("Pass")
print("Grade : E")
elif avg >=40:
print("Pass")
print("Grade : F")
else:
print("Grade : Failed")

## Assignment - use Nested condition: Take 3 numbers and put them
## in increasing order:
## 14, 13 13 => 13,13,14
# 19, 39,29 => 19,29,39
avg = 94
if avg>=40:
print("Pass")
if avg >= 90:
print("Grade A")
if avg>=95:
print("You win President's medal!")
elif avg >= 80:
print("Grade : B")
elif avg >= 70:
print("Grade : C")
elif avg >= 60:
print("Grade : D")
elif avg >= 50:
print("Grade : E")
else:
print("Grade : F")
else:
print("Grade : Failed")

num1= -0
if num1>0:
print("Number is positive")
elif num1<0:
print("Number is negative")
else:
print("0 - neither positive not negative")

# FOR Loop: when you know how many times to run the loop
# range(a,b,c) : start from a (including), go upto b (exclusive), increment by c
range(3,9,2) # 3,5,7 ... 8
print("For loop example 1:")
for i in range(3,9,2):
print(i)

print("For loop example 2:")
for i in range(3, 6): #range(a,b) => c=1 (default)
print(i)

print("For loop example 3:")
for i in range(3): # range(b) => a=0 (default) c=1 (default)
print(i)
# WHILE Loop: you dont know the count but you know when to stop
#LIST:  linear ordered mutable collection

l1 = [5,9,8.5,False,"Hello",[2,4,6,"Welcome"]]
print("Length: ",len(l1))
print(type(l1))
print(type(l1[1]))
print(l1[-3])
print(l1[-2][2])
print(l1[-1][-1][-1])

l2 = [10,20,30]
print(l1+l2)

print(l2 * 3)

files = ['abc.csv','xyz.csv','aaa.csv','bbb.csv','ccc.csv','ddd.csv']
for i in files:
print("I have completed",i)

#inbuilt methods for list
print("1. L2 = ",l2)
l2.append(40)
l2.append(60) #append will add members at the end
#insert()
l2.insert(3,50)
l2.insert(3,70)
print("2. L2 = ",l2)
l2.remove(50) #remove the given element
print("3. L2 = ",l2)
l2.pop(3)
#l2.clear()
print("4. L2 = ",l2)
l2 = [5,10,15,20,25,30,35,40]
print(l2.count(5))
l1 = [100,200,300]
l1.extend(l2) # l1 = l1 + l2
l1[0] = 999
print("L1 = ",l1)
l1.sort(reverse=True)
print("A. List1: ",l1)
l1.reverse()
print("B. List1: ",l1)

l2 = l1 #copy method 1 - deep copy: adds another name l2 to l1
l3 = l1.copy() #copy method 1
print("C1. List 1: ",l1)
print("C1. List 2: ",l2)
print("C1. List 3: ",l3)
l1.append(33)
l2.append(44)
l1.append(55)
print("C2. List 1: ",l1)
print("C2. List 2: ",l2)
print("C2. List 3: ",l3)
str1 = "hello"
str2 = str1.upper()
print(str2)
print(str1)
#l1

m1= int(input("marks 1:"))
m2= int(input("marks 1:"))
m3= int(input("marks 1:"))
m4= int(input("marks 1:"))
m5= int(input("marks 1:"))
total = m1+m2+m3+m4+m5
avg = total/5
print(m1,m2,m3,m4,m5)
print("Total marks = ",total," and Average = ",avg)

total = 0
for i in range(5):
m1 = int(input("marks:"))
total+=m1
avg = total/5
print("Total marks = ",total," and Average = ",avg)

marks=[]
total = 0
for i in range(5):
m1 = int(input("marks:"))
marks.append(m1)
total+=m1
avg = total/5
print(marks[0],marks[1],marks[2],marks[3],marks[4])
for i in marks:
print(i,end=" ")
print("\nTotal marks = ",total," and Average = ",avg)
########################
####
str1 = 'HELLO'
str2 = "I am fine"
str3 = '''Where are you going?
How long will you be here?
What are you going to do?'''
str4 = """I am here
I will be here for next 7 days
I am going to just relax and chill"""
print(type(str1),type(str2),type(str3),type(str4))
print(str1)
print(str2)
print(str3)
print(str4)

# What's you name?
str5 = "What's your name?"
print(str5)
#He asked,"Where are you?"
str6 = 'He asked,"Where are you?"'
print(str6)

#He asked,"What's your name?"
#escape sequence \
print('''He asked,"What's your name?"''')
print("He asked,\"What's your name?\"")

print('nnnnn\nnn\tnn')

print("\FOlder\\newfolder")
# \n is used to print newline in python
print("\\n is used to print newline in python")

# \\n will not print newline in python
print("\\\\n will not print newline in python")

str1 = "Hello You"
str2 = "There"
print(str1 + str2)
print(str1 *5)
for i in str1:
print("Hello")

#indexing
print(str1[2])
print("last element: ",str1[4])
print("last element: ",str1[-1])
print("second element: ",str1[-8])
print("ell: ",str1[1:4])
print("ell: ",str1[-8:-5])
print("First 3: ",str1[:3])
print("First 3: ",str1[:-6])
print("Last 3: ",str1[6:])
print("Last 3: ",str1[-3:])

#Methods - exactly same as your functions - only difference is they are linked to a class
import time
str1 = "HELLO"
print(str1.replace("L","X",1))

sub_str = "LL"
str2 = "HELLO HOW WELL ARE YOU LL"
cnt = str2.find(sub_str)
print("Count = ",cnt)

if cnt<0:
print("Sorry, no matching value hence removing")
else:
print("Value found, now replacing")
for i in range(5):
print(". ",end="")
time.sleep(0.5)
print("\n")
print(str2.replace(sub_str,"OOOO"))


out_res = str2.split("LL")
print("Output Result = ",out_res)

out_str = "LL".join(out_res)
print(out_str)

print(str2.title())
print(str2.lower())
print(str2.upper())

str3 = 'hello how well are you ll'
print(str3.islower())
print(str3.isupper())

num1 = input("Enter a number: ")
if num1.isdigit():
num1 = int(num1)
else:
print("Invaid input")

ename = input("Enter your first name: ")
if ename.isalpha():
print("Your name is being saved...")
else:
print("Invaid name")

#WAP to count of vowels in a sentence
para1 = "Work, family, and endless to-do lists can make it tough to find the time to catch up. But you'll never regret taking a break to chat with your friend, Frost reminds us. Everything else will still be there later."
sum=0
for l in para1:
if l=='a' or l=='A' or l=='e' or l=='E' or l=='i' or l=='I' or l=='o' or l=='O' or l=='u' or l=='3':
sum+=1
print("Total vowesl = ",sum)
sum=0
for l in para1.lower():
if l=='a' or l=='e' or l=='i' or l=='o' or l=='u':
sum+=1
print("Total vowesl = ",sum)

sum=0
for l in para1.lower():
if l in 'aeiou':
sum+=1
print("Total vowesl = ",sum)

########## LIST
#LIST
#collection of linear ordered items
list1 = [1,2,3,4,5]
print(type(list1))
print("Size = ",len(list1))

print(list1[0])
print(list1[-1])
print(list1[3])
print(list1[:3])
print(list1[-3:])
print(list1[1:4])

for i in list1:
print(i)

print([2,3,4]+[6,4,9])
print([2,3,4]*3)

str2 = "A B C D A B C A B A "
print(str2.count("D"))
print(list1.count(3))

l1 = [2,4,6,8]
print(l1.append(12))
print(l1)
l1[0]=10
print(l1)

l1.insert(2,15)
print(l1)

# Queue: FIFO
# Stack: LIFO

if 16 in l1:
l1.remove(16) #takes in value to remove
l1.remove(15)
print(l1)
l1.pop(1) #index
print(l1)

#################
while False:
print("Queue is: ",l1)
print("1. Add\n2. Remove\n3. Exit")
ch=input("Enter your choice: ")
if ch=="1":
val = input("Enter the value: ")
l1.append(val)
elif ch=="2":
l1.pop(0)
elif ch=="3":
break
else:
print("Try again!")

while False:
print("Stack is: ",l1)
print("1. Add\n2. Remove\n3. Exit")
ch=input("Enter your choice: ")
if ch=="1":
val = input("Enter the value: ")
l1.append(val)
elif ch=="2":
l1.pop(-1)
elif ch=="3":
break
else:
print("Try again!")

l2 = l1 #they become same
l3 = l1.copy()
print("1. List1 = ",l1)
print("1. List2 = ",l2)
print("1. List3 = ",l3)

l1.append(33)
l2.append(44)
l3.append(55)

print("2. List1 = ",l1)
print("2. List2 = ",l2)
print("2. List3 = ",l3)

l1.extend(l3)
print(l1)
print(l1.count(6))

sum=0
marks=[]
for i in range(3):
m = int(input("Enter marks in subject "+str(i+1)+": "))
marks.append(m)
sum+=m
print("Sum is ",sum, "and average is ",sum/3)
print("Marks obtained is ",marks)

#THREE STUDENTS AND THREE SUBJECTS:
allmarks=[]
for j in range(3):
sum=0
marks=[]
for i in range(3):
m = int(input("Enter marks in subject "+str(i+1)+": "))
marks.append(m)
sum+=m
print("Sum is ",sum, "and average is ",sum/3)
print("Marks obtained is ",marks)

allmarks.append(marks)

print("All the marks are: ",allmarks)

# All the marks are: [[88, 66, 77], [99, 44, 66], [44, 99, 88]]
# find the highest marks of each subject

#Tuple - linear order immutable collection
#strings are also immutable

tuple1 = (1,3,1,4,1,5,1,6)
print(type(tuple1))
print(len(tuple1))
print(tuple1.count(1))
print(tuple1.index(4))
print(tuple1[2])
for i in tuple1:
print(i)
t1 = list(tuple1)
t1.append(55)
t1=tuple(t1)
t2 = (2,4,6,8) #packing
#unpacking
a,b,c,d,e = t2
print(a,b,c,d)
#packing
# Dictionary
dict1 = {1: "Sachin Tendulkar","Runs": 50000, 'City':'Mumbai','Teams':['Mumbai','Mumbai Indians','India']}
print(dict1['Teams'])
dict2 = {'100s':[50,20,1]}
dict1.update(dict2)
print(dict1)
print(dict1.values())
print(dict1.keys())
print(dict1.items())

#Dictionary are mutable
dict1.pop('City')
print(dict1)
dict1.popitem()
print(dict1)

dict3 = dict1.copy() #shallow copy
dict4 = dict1 #deep copy

all_details={}
while True:
roll = input("Enter Roll Number of the Student: ")
marks=[]
for i in range(3):
m = int(input("Enter the marks: "))
marks.append(m)
temp={roll:marks}
all_details.update(temp)
ch=bool(input("Enter null to continue: "))
if ch:
break

print("All details: ",all_details)
for i, j in all_details.items():
sum=0
for a in j:
sum+=a
print(f"Total marks obtained by {i} is {sum} and average is {sum/3:.1f}")


### SET
'''
A B C D E
D E F G H
How many total (union): 8
How many common(intersection): 2
Remove set2 values from set1: (set1 - set2): 3

'''
set1 = {2,4,6,8,10,12}  #neither have duplicate values nor there is any order
print(type(set1))
set2 = {3,6,9,12}
print(set1 | set2)
print(set1.union(set2))
#print(set1.update(set2)) #meaning union_update
#print(set1)
print(set1 & set2)
print(set1.intersection(set2))
#print(set1.intersection_update(set2))
#print(set1)
print(set1 - set2)
print(set1.difference(set2))
#print(set1.difference_update(set2))
#print(set1)
print(set1^set2)
print(set1.symmetric_difference(set2))
#print(set1.symmetric_difference_update(set2))
#print(set1)

#####
## Functions

#defining a function
def sometxt():
print("Hello")
print("how are you?")
print("I am fine thank you!")
return "Great"

print(sometxt())
a= sometxt()
print(a)

#functions that return values v doesnt return values
# function taking input arguments /  pass - parameters
def function1(x,y,z): #required positional arguments
print("Value of X: ",x)
print("Value of Y: ", y)
print("Value of Z: ", z)

def function2(x,y=15,z=30): #default positional arguments
print("Value of X: ",x)
print("Value of Y: ", y)
print("Value of Z: ", z)

def function3(x,*y,**z):
print("Value of X: ", x)
print("Value of Y: ", y)
print("Value of Z: ", z)

function3(20, 2,4,6,8,10,12,14,16,18,20, fruit="Apple",calorie=150)
a=5
b=6
c=9
function1(a,b,c) #parameters
function2(12)

function2(z=30,x=12) #keywords (non-positional)

VIDEO- Function Types Intro

#Functions

def func1(num1,num2):
print("Number 1 = ", num1)
print("Number 2 = ", num2)
add = num1 + num2
print("Addition = ",add)
return add



def func2(num1,num2=100):
print("Number 1 = ", num1)
print("Number 2 = ", num2)
add = num1 + num2
print("Addition = ",add)
return add


#variable length arguments

def alldata(num1, num2, *var1, **var2):
print("Number 1 = ",num1)
print("Number 2 = ", num2)
print("Variable 1 = ", var1)
print("Variable 2 = ", var2)

if __name__ =="__main__":
result = func1(5, 10) # required positional arguments
result = func2(5) # num1 is required / num2 is default & positional arguments
print("Result of addition is", result)

result = func2(num2=5, num1=25) # keyword arguments (non-positional)
print("Result of addition is", result)

alldata(5, 83, 12, 24, 36, 48, 60, name="Sachin", city="Pune")

# class - definition
# class str - defining some properties to it like split(), lower()
# object is the usable form of class
str1 = "hello"

#creating a class called Library
#in that I added a function called printinfo()
# self: indicates function works at object level
class Library:
#class level variable
myClassName = "Library"

#__init__ - it has predefined meaning (constructor), called automatically
#when you create an object
def __init__(self):
name = input("Init: What's your name?")
self.name = name # self.name is object level

# object level method
def askinfo(self):
name = input("What's your name?")
#self.name = name #self.name is object level

#object level method
def printinfo(self):
myClassName="Temp class"
print(f"{Library.myClassName}, How are you Mr. {self.name}?")

#create object
l1 = Library()
l2 = Library()
l3 = Library()
#l1.askinfo()
#l2.askinfo()
#l3.askinfo()

l2.printinfo()
l3.printinfo()
l1.printinfo()