ADVANCED PROGRAMMING CONCEPTS - Python
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
Due to internet/network connectivity issue,
I will be conducting lecture on YouTube.
For Facebook Event of above Session (Optional) : Register here
Python Programs:
Lecture will start at sharp 16:00 today.
Please attend it. And if you have any questions then
please ask in Comment box below the video.
In this Session, I have covered following points:
Python functions
Due to Internet connectivity issue making premiered video can be great tool
where without any kind of interruption students can watch lecture video.
YouTube Session - 31st Oct. 2020
ADVANCED PROGRAMMING CONCEPTS - Python (TY A and B)
Punyashlok Ahilyadevi Holkar Solapur University.
TY Mechanical Engineering Students.
Punyashlok Ahilyadevi Holkar Solapur University.
TY Mechanical Engineering Students.
Ref.: https://www.w3schools.com/python/
For more clarity please watch YouTube video with 360p or 480p Quality.
Please click on the three vertical dots on video then select Quality option.
Then select resolution as 360p or 480p.
Please write you Name and Roll Number in Live Chat Box/Comment Box (below Video in YouTube) to capture your attendance.
YouTube Video Lecture:
This video is premiered it will start at sharp 16:00 pm today.
To ask questions in Chat Box/Comment Box :
Python Programs:
# Python Functions
# A function is a block of code which only runs when it is called.
# You can pass data, known as parameters, into a function.
# A function can return data as a result.
# Creating a Function
# In Python a function is defined using the def keyword:
# Example
def my_function():
print("Hello from a function")
print("I am in Pandharpur")
# Calling a Function
# To call a function, use the function name followed by parenthesis:
my_function()
Output:
Hello from a function
I am in Pandharpur
# Arguments
# Information can be passed into functions as arguments.
# Arguments are specified after the function name,
# inside the parentheses.
# You can add as many arguments as you want,
# just separate them with a comma.
def my_function(uname):
print(uname + "@coe.sveri.ac.in")
my_function("sdbhosale")
my_function("fmsurname")
#my_function(1) #TypeError: unsupported operand type(s) for +: 'int' and 'str'
#my_function(1.1) #TypeError: unsupported operand type(s) for +: 'float' and 'str'
Output:
sdbhosale@coe.sveri.ac.in
fmsurname@coe.sveri.ac.in
Information
# Parameters or Arguments?
# The terms parameter and argument can be used for the same thing:
# information that are passed into a function.
# From a function's perspective:
# A parameter is the variable listed inside the parentheses in the function definition.
# An argument is the value that is sent to the function when it is called.
# Number of Arguments
# By default, a function must be called with
# the correct number of arguments.
# Meaning that if your function expects 2 arguments,
# you have to call the function with 2 arguments,
# not more, and not less.
def my_function(fname, lname):
print(fname + " " + lname)
my_function("Rahul", "Shinde")
#my_function("Rahul")
# def my_function(fname):
# print(fname + " ")
#
# my_function("Rahul", "Shinde")
Output:
Rahul Shinde
#Arbitrary Arguments are often shortened to *args in Python.
# Arbitrary Arguments, *args
# If you do not know how many arguments
# that will be passed into your function,
# add a * before the parameter name in the function definition.
def my_function(*kids):
#print("The youngest child is " + kids[0])
#print("The youngest child is " + kids[1])
#print("The youngest child is " + kids[2])
print("Children are " + kids[0],",",kids[1],"and",kids[2])
my_function("Rajesh", "Ramesh", "Ganesh")
Output:
Children are Rajesh , Ramesh and Ganesh
# Keyword Arguments
# You can also send arguments with the key = value syntax.
# This way the order of the arguments does not matter.
#The phrase Keyword Arguments are often shortened to kwargs in Python.
def my_function(child3, child2, child1):
print("The youngest child is " + child3)
#print("The youngest child is " + child2)
#print("The youngest child is " + child1)
my_function(child1 = "Rajesh", child2 = "Ramesh", child3 = "Ganesh")
Output:
The youngest child is Ganesh
# Arbitrary Keyword Arguments are often shortened to **kwargs in Python
# Arbitrary Keyword Arguments, **kwargs
# If you do not know how many keyword arguments
# that will be passed into your function,
# add two asterisk: ** before the parameter name
# in the function definition.
# This way the function will receive a dictionary of arguments,
# and can access the items accordingly:
def my_function(**kid):
print("His first name is " + kid["fname"]) # + or ,
print("His last name is " + kid["lname"]) # + or ,
my_function(fname = "Rahul", lname = "Shinde")
Output:
His first name is Rahul
His last name is Shinde
# Default Parameter Value
# The following example shows how to use a default parameter value.
# If we call the function without argument, it uses the default value:
def my_function(country = "India"):
print("I am from " + country)
my_function("Sweden")
my_function() #default parameter value will be taken as country=India.
my_function("Brazil")
Output:
I am from Sweden
I am from India
I am from Brazil
#Passing a List as an Argument
def my_function(food):
for x in food:
print("Values of fruits list=",x)
fruits = ["apple", "banana", "cherry"]
my_function(fruits)
Output:
Values of fruits list= apple
Values of fruits list= banana
Values of fruits list= cherry
# Return Values
# To let a function return a value, use the return statement:
def my_function(x):
return 5 * x
print(my_function(3))
print(my_function(5))
print(my_function(9))
Output:
15
25
45
# The pass Statement
# function definitions cannot be empty,
# but if you for some reason have a function definition with no content,
# put in the pass statement to avoid getting an error.
def myfunction():
pass
#pass #it gives error
output:
Present Roll Numbers and Names:
Vaibhav Bhosale TB13
TYB_73 vaibhav Jagtap TB73
Suraj More TYA_45 - suraj more
Samruddhi Deshpande TYB_01
SALIM SHAIKH TY B 45
Yash Gadekar TYA_25
SAMARTH CHAVAN TA 15
manthan dixit TYB16
TYB_33 Ridham Parmar TYB_33
pranay disale TYA_50
VINAYAK Gawali TYA_72
TYB_41 Yasar Khatik TYB_41
TYA_64 Sohel Shikalgar TY A 64
ADESH BANKAR TYB_09
ABHI KHOTE TYB_22 Abhijit khote
TYA_44 Mangesh Misal TYA_44
TYA_73 Ashley Thomas TYA_73
bharat burungale TA14
Shraddha gajakosh TYA_02
Pravin Somdale TYA_65
Akshay Pansare TA43
Harshvardhan Ubale TYB_50
SALIM SHAIKH TYB_45
Its_Pranav_ Show TYB 59
sumit Patwari TYB_77
TYA_35 Parchandrao Chandragupta Vinayak TYA_35 Parchandrao Chandragupta Vinayak
TYB_22 Abhijit Khote TYB_22 Abhijit khote
Sachin Waghmare TA49
Nikhil Mundhe TYA47
Santosh Patil TYB_35
deepjyoti sathe TA08
Vinayak Bapat TYB_11
Hritik Bhosale Hritik Bhosale TYB 12
Ganesh Todkar TA24
Saurabh Nikam TYB-32
TYB_17 Abhinay Gaikwad TB17
TYA_05 Saleha Mirjkar [message retracted]
TYB_17 Abhinay Gaikwad Abhinay Rajendra Gaikwad TB17
Jaydev Nanaware TYB_31
Dhanashree Sonawane TYB06
saurabh chavan TYA_16
aniket bansode TYB_10
Learning is essential. Learn Free TYB54
OMKAR PAWAR TYB_37
Samarth Mane-Deshmukh TYA_51
Vijay Mali TYB_26 AMOL MALI
PrerAna Ekatpure TYB_02
Madhuri Parchandrao TYA_06
Milind Jagadale TYA_34
parasmule mule TYA_58
Saurabh Wadekar TYB 55
TYB_41 Yasar Khatik TYB_41
Vaishnavi Lakheri TYA_04
TYB_70 Akash Mane TYB_70
TYB_17 Abhinay Gaikwad TB17
Komal Achugatla TYA_01
Saleha Mirjkar TYA-05
TYB_42Kashiling Sarak TYB_42
TYB_34 Madan Patil TYB_34
Hrishav raj rai TYB_39
TYB_05 Vaishali More TYB_05
onkar deokar TYA2w
onkar deokar TYA22
Namrata Parvat TYA_07
Nilesh Kadam TB-21
TYB_41 Yasar Khatik TYB_41
TYB_03 Arati Lale TB 03
TYB_17 Abhinay Gaikwad TB17
Sushant Jadhav 𝙏𝙔𝘽_65
Harshvardhan Ubale TYB_50
Saurabh Chavan TA_16
TYA_35 Parchandrao Chandragupta Vinayak
TYA_73 Ashley Thomas
TYB_44 Aftab Shaikh
TYB_34 Madan Patil
TYB_10 Aniket Bansode
No comments:
Post a Comment