In this Python Beginner Tutorial, we will begin learning how to write functions. Functions are one of the most important things to learn in Python Programming and will take us to the next level. We will learn how to create/define functions, how to pass in arguments, and also how to return values. Let’s get started.
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python-Functions
Watch the full Python Beginner Series here:
https://www.youtube.com/playlist?list=PL-osiE80TeTskrapNbzXhwoFUiLCjGgY7
Scope Video: https://youtu.be/QVdf0LgmICw
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website – http://coreyms.com/
Facebook – https://www.facebook.com/CoreyMSchafer
Twitter – https://twitter.com/CoreyMSchafer
Google Plus – https://plus.google.com/+CoreySchafer44/posts
Instagram – https://www.instagram.com/coreymschafer/
#Python
Amazon Auto Links: No products found.
It is great courses here, Thank you so much Corey
one question here, I didn’t get why use ‘and’ condition with (year % 100 != 1 or year % 400 == 0) , I think (year % 4 ==0) is enough I tried first condition with many years and working good.
14:10 Who else noticed a slight change in his voice?
It is great courses here, Thank you so much Corey
one question here, I didn’t get why use ‘and’ condition with (year % 100 != 1 or year % 400 == 0) , I think (year % 4 ==0) is enough I tried first condition with many years and working good.
No doubt awesome video! But, does this mean I don’t have to use main() to execute my functions in a program?
I must admit Python is pretty darn elegant. It does so much in so few lines.
ugh. so confusing
TIL that not every century turn is a leap year. I did not know that….had to look it up to prove myself wrong.
Awesome explanations
The word def in Python means define not definition even thought it’s pretty much the same thing.
Is there a video on sorting algorithms?
Is there an option that we can do like “def function_name(*args,**kwargs,**kwargs)” to pass more variables? Thanks
Hey Corey!
Thanks a lot for your videos! I’m bit confused with the use of parentheses ( ), brackets [ ] and curly braces { }.
In this video, you use curly braces { } to pass arguments into the function for example. But from an earlier video, you told they are used for Sets and Dictionaries.
In other cases, brackets [ ] are being used.
Overall it is not intuitive what to use (parentheses ( ), brackets [ ] or curly braces { } ) in diferent cases.
Very comprehensive. So GET Rest Api basically runs functions, hope you have tutorial on that too.
These videos are too good. Python official tutorial is very confusing, it advanced BS example which are non sense.
whst ide are you using?
Crisp, solid and well paced explanations. These videos are a godsend, thank you for making these.
! You teach in style!!. Thanks great man!
Good explanation. Thanks
https://goo.gl/PsqQhk
0:27 absolutely thoughtless font size and recording setting u are working with. Why so much empty screen……. !!!!!????
Everything else was fine.
Can i know the editor name?plz
Instantly subbed after watching one of your videos. This is the best Puthon channel I’ve seen. Keep up your Great work
print(” Karenderya”)
print(” (Please fall in line)”)
print(“Menu: n 1.) Breakfast (Combo Meal) n 2.) Lunch (Combo Meal) n 3.) Drinks n 4.) Dessert”)
menu = {
“1” :”Breakfast”,
“2” :”Lunch”,
“3” :”Drinks”,
“4” :”Dessert”
}
choice = input(“Enter your category 1:”)
print(menu.get(choice, “Invalid”) )
while True:
if choice == “1”:
print(” A1.) Tapsilog – P60 n A2.)Longsilog – P50 n A3.)Hotsilog – P45″)
elif choice == “2”:
print(” B1.)Pakbet w/ rice – P35 n B2.)Sinigang na Baboy w/ rice – P50n B3.)Nilagang Baboy w/ rice – P50″)
elif choice == “3”:
print(” C1.)Iced Tea – P20 n C2.) Botteled Water – P12n C3.)Soda – P25″)
elif choice == “4”:
print(” D1.)Brownies – 25 n D2.) Butterscotch – P25 n D3.) Turon – P10″)
break
while True:
choice_a = input(“Enter your order:”)
if choice_a == “A1″:
print (” Tapsilog – P 60′”)
elif choice_a == “A2″:
print(” Longsilog – P 50″)
elif choice_a == “A3″:
print(” Hotsilog – P 45″)
#===========================================
if choice_a == “B1″:
print (” Pakbet w/rice – P35″)
elif choice_a == “B2″:
print(” Sinigang na baboy w/ rice – P50″)
elif choice_a == “B3″:
print(” Nilagang Baboy w/ rice – P50″)
#===========================================
if choice_a == “C1″:
print (” Iced Tea – P20″)
elif choice_a == “C2″:
print(” Botteled Water – P12″)
elif choice_a == “C3″:
print(” Soda – P25″)
#============================================
if choice_a == “D1″:
print (” Brownies – P25″)
elif choice_a == “D2″:
print(” Butterscotch-P25″)
elif choice_a == “D3″:
print(” Turon- P10″)
else:
print()
break
print(” To compute the price:”)
print()
price = int(input(“Enter the price:”))
pcs = int(input(“How Many Pieces? :”))
t_price = price*pcs
print(“Total Price:” , t_price)
print(” To compute the change:”)
print()
customer_money=int(input(“Enter the money of your customer: “))
print(“Change:”, customer_money – t_price)
print(“Thank you for your order :-)”)
How can i input the function for this?
Appreciate the content, thank you but way too small on an iphone
a=int(input(‘enter a no’))
print (a)
It’s giving an error…that invalid literal for int() with base 10: ‘ ‘
Hi, I am new to pyhton, just wandering when when do u ues () and []?
Thank you and pretty good
Thank you sir
hi, Sir i have a question . i write this simple code in python idle but when i write and run in sublime it executed . will you pls explain the reason , here i the code.
def cals():
a=12
b=2
return(a*b)
print(cals())
Thanks for the excellent tutorial.
Found some useful information here as well for someone who might be interested.
https://treyhunner.com/2018/04/keyword-arguments-in-python/
bro……..thanks for https://www.youtube.com/watch?v=nt7yoAeEtkQb
I tweeted this, TY for these videos
00:00 def intro
07:00 passing arguments
10:27 args & kwargs
15:01 example
too complicated!!! make it simple!
SUBBD, BELLD FAPP- oh nvm too much
What’s interesting about Python functions is that in Python function body’s are treated as values and stored in local symbol table. That value (function-body) can be applied to another name (function-name) and then that name (function) will act same as previous function. Just like variables.
Thanks.
doing computing GCSE and your videos have really helped me – thanks bro 🙂
I love that your videos are FAST paced, CLEAR with no idle chatter and with QUICK examples that show every aspect of what you are teaching. Of all the Python tutorials, yours are the best. 🙂