Python Tutorial 16: Understanding Python Functions

  Рет қаралды 23,803

Paul McWhorter

Paul McWhorter

3 жыл бұрын

You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
In this video we show step-by-step instructions on how to use python functions. I do not assume you are an expert, so these lessons are designed for complete beginners.
#Python
#Lessons
#Programming

Пікірлер: 81
@RobVollmar
@RobVollmar 2 жыл бұрын
I ended up watching and working through the examples in this video three times before I felt like I understood it well enough to attempt the homework. I worked out the code by hand in a notebook before entering it into the VSC environment. It took a little bit of code testing before I finally understood how information gets passed between the function and the program but I'm pleased as punch to tell you that I AM LEGEND. I appreciated the bit you said at the end about nipping code from previous efforts because that's exactly what I did and it felt like just the right amount of work even without reinventing the wheel!
@fatherloz2800
@fatherloz2800 2 жыл бұрын
Just a suggestion for everyone: at this point in time I installed some extensions in VSC that makes coding much more efficient like 'Prettier', 'Bracket pair corolizer'. I also changed the color of the cursor and the line number on the left side and the left bar(?). This makes everything stand out, and the changes that can be applied are limitless. Also made shortcuts to clear the terminal and run the program with their own specific keyboard button. I encourage you to try extensions :). Now on with this tutorial, thanks Paul, Cheers all !
@maku5289
@maku5289 Жыл бұрын
which extensions do you suggest and where can we find them? Thanks
@426F6F
@426F6F 8 ай бұрын
It took me a long time to begin to wrap my head around functions because it felt like there was so much going on, but I think I finally understand them. I just finished the homework! Great lesson Paul!
@hughpatterson1480
@hughpatterson1480 2 жыл бұрын
Another homerun! Great Lesson. It's a really great explanation for students. Clear and concise. I'll be sending the class here for extra help. Thanks Paul!
@mikekeller7342
@mikekeller7342 3 жыл бұрын
Thanks Paul! Great lesson, and great homework assignment!
@boydrogers7227
@boydrogers7227 3 жыл бұрын
Folding lawnchairs having been kept at bay yet again, the legend continues. Thanks, Paul.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
THE LEGEND CONTINUES! Good Job, Boyd
@LorenBurdette
@LorenBurdette Жыл бұрын
Great Lesson! Thank you.
@harshjee4134
@harshjee4134 3 жыл бұрын
Hello Mr.Mcwhorter, Now i am following you for a while and i am grateful to you for providing such quality content for free, Your videos has made me fall in love with electronics and programming. I'm a student but when i get my first paycheck, it will be dedicated to your patreon. Thanks again sir, You're the coolest :)
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Best of luck!
@ricklawitzky8311
@ricklawitzky8311 2 жыл бұрын
Great lesson!
@mohsenr4434
@mohsenr4434 2 жыл бұрын
Amazing. Thank you.
@guyinternet2018
@guyinternet2018 2 жыл бұрын
Thanks a lot for your contribution 🙏🏻
@MrElFRanz
@MrElFRanz 3 жыл бұрын
Hello Paul. Thanks for your lessons. I have done the homework of lesson 16.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Excellent!
@opalprestonshirley1700
@opalprestonshirley1700 3 жыл бұрын
Enjoyed this lesson. Good job covering the scope of variables. The homework will be a bit of fun. See you next week.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Have fun!
@davidschnider1297
@davidschnider1297 Жыл бұрын
thanks, Paul.. that was indeed FUN... a bite size chunk of Python Code... to chew on and digest,. The Function definition, call, and return .. COOL..
@johnplowright6421
@johnplowright6421 2 жыл бұрын
Another great lesson and homework assignment, really got me thinking of the best use for these functions, I made a print function to print the arrays of names and grades so I could pass the entered lists and then after my sorting function use the same print function but passed the sorted arrays big smiles from me when it all works. A mistake is only an error if it remains uncorrected.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Fantastic!
@maku5289
@maku5289 Жыл бұрын
Sir, you are a machine. Love it 💥☕
@raymondwood3603
@raymondwood3603 7 ай бұрын
Great video
@mattphorwich
@mattphorwich 3 жыл бұрын
I love the videos!! Excited to learn!! God bless the multiverse!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
More to come!
@nielsroetert
@nielsroetert 2 жыл бұрын
Catching up on these lessons, great to be back after a couple of weeks off. This is another fun one, starting on the assignment now.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
In order to avoid an unexcused absence, we will need a note from someone. A doctor, your mom, someone, but we will need a note.
@nielsroetert
@nielsroetert 2 жыл бұрын
@@paulmcwhorter man you are strict 🤣
@cubbyhoo
@cubbyhoo 3 жыл бұрын
Hope your going to include list comprehensions in your tutorials Paul!You could do this function in one line (I haven't used an input in one before but I don't see why not!) return [float(input("Enter your number")) for i in range(nums)] Would do it. Ps keep up the excellent work!!!! I just finished my first year of Electronics and Software Engineering. Your always insuring me!
@manewry66tw
@manewry66tw 3 жыл бұрын
Very original way of coffee consumption. I like the glass.
@honeybadger6388
@honeybadger6388 3 жыл бұрын
is it a coffee shop or ????
@rafabaez
@rafabaez 2 жыл бұрын
Mr Mcworther: As usual, thank you for your passion an lessons. Given your background, we know you do not need any money for yourself. We believe that you are probably using those patrion resources to help people in Africa. If so, I admire you even more. Thank you.
@davidschnider1297
@davidschnider1297 Жыл бұрын
phew... the 'in class' homework was a bit of a struggle.. working out how to append .. but got it done .. and completed the homework too... enjoying the lessons... thanks, Paul... God bless...( ooops,.. this comment belongs to an earlier lesson .. #14, I think .. ) looking forward to THIS lesson...
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Fantastic!
@bryankohn9660
@bryankohn9660 3 жыл бұрын
OK I was on vacation and just got to this. Finished the assignment (including the sort grades function) and it works! However, it does not seem all that neat or readable so I can't wait to see how you do it in Lesson 17.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Great job!
@pralaymajumdar1206
@pralaymajumdar1206 3 жыл бұрын
Really fun.. Enjoy a lot as usual. Thank you sir.. Be safe and take care in this pandemic because you are looking affected with little cold and caugh. Take stream of hot water.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Actually allergies. This was recorded some time ago, I am fine
@thirupathaiah2981
@thirupathaiah2981 2 жыл бұрын
Good tutorials sir
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Glad you like them!
@advancedperformance9721
@advancedperformance9721 2 жыл бұрын
Great 👍
@eeshaangupta9120
@eeshaangupta9120 3 жыл бұрын
sir currently I am watching your arduino tutorials and you teach really awesomeeee
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Glad to hear that
@ludwigmalan6590
@ludwigmalan6590 2 жыл бұрын
if you want to disable popups do this: 1.go to settings 2.in search settings panel type hover 3.the hover settings should display 4.then turn off hover enabled
@shaggy7958
@shaggy7958 5 ай бұрын
I did mine differently but it worked just as well. Instead of using two arrays in "parallel", I used only one array where each element is a name and a grade. After reading the array back using the 'pickle.load()' function, I used the 'len()' function to determine how many elements are present.
@bhk5003
@bhk5003 2 жыл бұрын
You are the legend ^^ ....
@darklightining6412
@darklightining6412 Жыл бұрын
Can't thank you enough ^^.
@kirubeltekle9553
@kirubeltekle9553 Жыл бұрын
I love you paul
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Thanks!
@dzeykop
@dzeykop Жыл бұрын
Thank you Sir, another great lesson! Your lessons are not wasted time (#NWT) for me and that is exactly what I want! 👍
@easydatascience2508
@easydatascience2508 Жыл бұрын
see mine too. The playlist contains almost all the fundamentals of learning Python. Hope the tutorials and source files will be helpful. There is another playlist in the channel, R beginning course.
@tomwolf6353
@tomwolf6353 3 жыл бұрын
It would be awesome if you would create a practical Git & GitHub tutorial. 🚀
@nickmcroft
@nickmcroft 9 ай бұрын
@paulmcwhorter Paul, really enjoying your lessons. Can’t thank you enough for paving my coding journey. Re this video…. Was wondering on the significance of using range method in for loop as opposed to simple for i in x type method. Below I’ve posted both methods. They both do the same job but the for i in x: is much simpler. Range method… digits=5 num=[2,4,6,8,10] def sum(x,y): tot_num=0 for i in range(0,x): tot_num+=y[i] print(f'Using for loop range, Total of {y}: {tot_num}') sum(digits,num) Other method… def sum_2(x): sum = 0 for i in x: sum+=i print(f'Sum of x: {sum}') sum_2(num) Is using the range method purely for teaching or is it better? Cheers!
@bkairosh8164
@bkairosh8164 3 жыл бұрын
I'm curious to find out why the print operation that is inside the function is displayed when we run the main code. I thought the function only returns the variable z, and the print(afun) and print(bfun) are not assined to z.
@mannatkaur1146
@mannatkaur1146 3 жыл бұрын
Please include list comprehensions in one of your lessons. It is a crucial topic which I don't know. Even though I tried going through some online stuff, but was not able to get a hang of its working
@amayaphotos8016
@amayaphotos8016 Жыл бұрын
I think i got the assignment all correct.
@giuliaesposito3071
@giuliaesposito3071 3 жыл бұрын
"...or die trying" I like the method of this man, subscribed. ps: method is a joke :D
@danielduplessis7221
@danielduplessis7221 2 жыл бұрын
I Am Legend!
@mun5660
@mun5660 2 жыл бұрын
Is there a way to take all myNum values in one line then listing them out in append rather than continuously asking for an input in time?
@lissisland5116
@lissisland5116 2 жыл бұрын
def like(a,b): z=a+b return z name=('Paul McWhorther - ') gratitude=("Thank you") sentence=like(name,gratitude) print(sentence)
@chalmerditmars7037
@chalmerditmars7037 Жыл бұрын
I assume Paul is teaching with a simple editor and no packages so that we understand Python before installing packages. I went through a four hour tutorial that was supposed to teach Python. In there I followed and wrote a rock, paper, scissor game, and at last a blackjack game. Both functioned after hours of staring at the screen looking for something different on mine than his. I really could not figure out the logic of either game. After a week and a half here I think I could look and figure what in the world happened in those games to make them tick.
@kiarie_john3093
@kiarie_john3093 3 жыл бұрын
Please introduce cyber security tutorials, thanks.
@alejandroperez5368
@alejandroperez5368 3 жыл бұрын
What do you think he is? An encyclopedia?
@nyrootu9954
@nyrootu9954 3 жыл бұрын
@@alejandroperez5368 He's a man of God and therefore capable of being more than an encyclopedia
@jonorgames9880
@jonorgames9880 3 жыл бұрын
Interesting. Actually, it seems, that pickle is extremely bad security wise.
@noweare1
@noweare1 2 жыл бұрын
I am surprised that worked as y was not declared an array as in y[ ]
@user-ng6to7wq9h
@user-ng6to7wq9h 2 ай бұрын
I get it now but haaa!, coding is really something 😅
@CorciCORCI-rh8ql
@CorciCORCI-rh8ql Күн бұрын
I did'nt understand why he write return z 8:32
@ritwikkaushik4026
@ritwikkaushik4026 3 жыл бұрын
I m legend
@thisismyworkshop6654
@thisismyworkshop6654 2 жыл бұрын
Chai latte this time. I'm sorry, I hope I won't get a ban 😄
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Hope you dont have sugar in that chai. That will get you banned!
@thisismyworkshop6654
@thisismyworkshop6654 2 жыл бұрын
@@paulmcwhorter If the bartender put sugar in my chai latte, that could be considered a sabotage I guess!
@Lehibob
@Lehibob 2 жыл бұрын
I am legend. I have completed and posted my homework for this lesson. I finally broke down and added a screen capture and webcam element to my video. Please advise if anyone notices that the image of the guy in the camera damages your monitors, glasses, retinas, etc. The link for this is : kzbin.info/www/bejne/bmWmoXZ7bqulga8
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
And now we know what you look like! Thats the best part, I like seeing the faces behind the comments.
@stevesopenrocket
@stevesopenrocket 3 жыл бұрын
As always I learned alot, but I do have a question. Is there not a method or function in python to return the length of an array/list? If not, Is there a way to find out programmatically?
@TroyCroatto
@TroyCroatto 3 жыл бұрын
There is, I am sure Paul will teach it soon, but you can use len(x), if it is an array I think it will give the amount of items in there, if its on a string I think it returns the amount of characters. I am a bit rusty but that should work
@nielsroetert
@nielsroetert 2 жыл бұрын
@@TroyCroatto This is very true, but pretty sure Paul is staying away from these on purpose, so people think about solving these things manually and get a better learning experience.
@Joel-pl6lh
@Joel-pl6lh 2 жыл бұрын
Check his for loop video, I think you can figure out by yourself or check my solution: counter=0 fruits=[1,7,"apple","orange"] for i in fruits: counter=counter+1 print(counter) This for loop is not using "in range(...)", instead it goes through the loop for each item in the array. So if you add 1 to a variable inside the loop, you will get the length of the array. (Don't forget to initialize the counter to 0 before the loop)
@Aditikaushik6347
@Aditikaushik6347 3 жыл бұрын
​def add(x,y): ​ x+y
@tejkhanvilkar5743
@tejkhanvilkar5743 3 жыл бұрын
hello Paul please check your email. I am having some droughts
Python Tutorial 17: Python Functions Examples and Solutions
27:45
Paul McWhorter
Рет қаралды 15 М.
Python Tutorial 18: Understanding Python Methods and Classes
42:43
Paul McWhorter
Рет қаралды 24 М.
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 37 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 54 МЛН
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 3,3 МЛН
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
Python Tutorial 14: Saving and Reading Data Files With Pickle
22:57
Paul McWhorter
Рет қаралды 28 М.
Functions in Python are easy 📞
10:38
Bro Code
Рет қаралды 415 М.
Python Tutorial 19: Python Classes and Methods Homework Examples
57:57
Stanford's FREE data science book and course are the best yet
4:52
Python Programmer
Рет қаралды 673 М.
Python Object Oriented Programming (OOP) - For Beginners
53:06
Tech With Tim
Рет қаралды 3,3 МЛН
All 39 Python Keywords Explained
34:08
Indently
Рет қаралды 129 М.
Concurrency in Go
18:40
Jake Wright
Рет қаралды 609 М.
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 766 М.
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 337 М.
Хотела заскамить на Айфон!😱📱(@gertieinar)
0:21
Взрывная История
Рет қаралды 6 МЛН
В России ускорили интернет в 1000 раз
0:18
Короче, новости
Рет қаралды 1,8 МЛН