Below is an outline of this video. 0:41: How to use sample files 1:41: Using comments 2:21: What’s a function? - Example 1 4:57: What’s a function? - Example 2 7:09: A function that takes multiple arguments 7:58: What’s a function? - 2 more examples 10:30: Creating a BMI calculator Also, a few tips: 1. Here is the playlist for this series: kzbin.info/www/bejne/kGK8lWqrpbamjrs 2. Follow along as I explain to make sure you understand everything 3. Ideally, work with a friend so you can help each other when you’re stuck 4. If you want to learn faster than I talk, I’d recommend 1.25x or 1.5x speed :) 5. Check the outline in the comment section below if you want to skip around. 6. Download the sample files here to follow along (they are Jupyter Notebook files): www.csdojo.io/python3 7. To make sure you don’t miss my future tutorial videos, sign up to my newsletter: www.csdojo.io/news 8. Have fun! If anything is unclear, please let me know in a comment.
@namlehai27376 жыл бұрын
local host... did you make all that?
@Jass_96766 жыл бұрын
Love from india Helpful videos
@harisar176 жыл бұрын
Again i hit like for your video..
@gilangvirgiawan27806 жыл бұрын
Ur something thanks
@parveshkhatri79716 жыл бұрын
Hi YK , In india we are not taught what we want . There is useless matter in our syllabus. Even many people with master degree in computer science can't create any simple application without any GUI interface help and swing controls. They teach us for marks not for knowledge. Should I learn computer science online leaving my school ?
@emanjavascript83585 жыл бұрын
men i watch every advertisement that comes out to my screen just to be fair by teaching us for free..your awesome men
@warframeees80134 жыл бұрын
Eman JavaScript watching the entire ad wont give him more revenue but a nice act nevertheless
@aarohansharma45514 жыл бұрын
It only gives revenue to KZbin or something I guess
@warframeees80134 жыл бұрын
Aarohan Sharma it doesn’t matter how long you watch the ad it’s per view, doesn’t matter if you skip the ad 5 sec in or watch the entirety
@katharina...4 жыл бұрын
@@warframeees8013 It does matter how long a viewer watches a skippable ad for. If a viewer skips it, the uploader doesn't get paid at all, you have to watch it for 30 seconds or longer for the uploader to be paid.
@warframeees80134 жыл бұрын
Katharina interesting if thats true
@kei71503 жыл бұрын
I'm skipping school to learn coding from this guy and i gotta say it's worth it.. this dude is way better than all of my teachers
@mikesierra143 жыл бұрын
I am doing this aswell.
@ragdoll3122 жыл бұрын
@@mikesierra14 *im Dont ask why
@Zainkhan-tk7kt2 жыл бұрын
@@ragdoll312 * I'm * Don't
@mattoucas8692 жыл бұрын
@@Zainkhan-tk7kt lol
@buspsychologist96402 жыл бұрын
@@Zainkhan-tk7kt * I am * Do not
@salman21983 жыл бұрын
Hello CS Dojo. I don't know if you are going to read this, but I just passed an Exam in Python because of you! Thank you so much! I spend like 10 hours to watch your awesome lectures :)
@mustafaaljanabi48183 жыл бұрын
Masha Allah! Well done brother!
@AS-nx9fu3 жыл бұрын
@ツMoon Owner - Owner of the Moon tf is he typing like that for? 😭💀
@joeroganpodfantasy422 жыл бұрын
But his lecture are around 3 hours? Do you mean total watching and practicing or just watching and rewatching?
@salman21982 жыл бұрын
@@joeroganpodfantasy42 Sorry for the late answer. Yes, by re-watching and doing everything by myself twice to get it :)
@ramajyello2 жыл бұрын
@@AS-nx9fu I deleted that acc 😂. Literally just stumbled upon this. Ig my path has been set in stone
@thatwakandaboy2 жыл бұрын
I am 4 years late to this channel and 43 years late to Programming, but I am enjoying every minute of this series. Thanks YK and the entire CS Dojo team.
@Addistoday Жыл бұрын
😂😂😂😂😂😂😂 same here,Things happen at Gods will time. enjoy❤❤❤❤ much love from Ethiopia🇪🇹
@ammarahmed81555 жыл бұрын
I started watching these tutorials yesterday and I figured out by myself how to use these functions to create a program to solve the quadratic formula. I know thats probably nothing for coders but I feel really accomplished and if anyone wants to see the code I can send it to you over email. I just feel really accomplished and I wanna share it with someone. This guy is such a good teacher.
@gabz84695 жыл бұрын
Hi Ammar Would you be able to send the code to geebee71@hotmail.com please? Appreciated..Thanks
@YashSharma-nm1zc4 жыл бұрын
Pls share me codes
@oblivious70454 жыл бұрын
Why don't you just post it in the comments?
@Aminhirari4 жыл бұрын
Be careful it’s a virus torchan
@ykyk77714 жыл бұрын
Post it here bruh
@dhruvalraval80786 жыл бұрын
You are being so helpful. Please continue with this series of python
@youdonthaveto3 жыл бұрын
You are so helpful. I've grown up in a broke family and I don't have any money to buy course for learning Python. Your videos mean a lot to me. Thank you so much Dojo
@FirepowerIGuess Жыл бұрын
I'm so glad people like CS are making these tutorials for free, genuinely. I hope you're in a more financially stable condition now than before.
@3niracer Жыл бұрын
Learned more from you in an hour than 2 weeks of a course. Thanks for taking the time and effort. Much appreciated 🙏🏽
@Haldiki3 ай бұрын
Saying thank you is saying nothing at all It's the first time that I've understood programming without a sweaty forehead. CS Dojo is like a real teacher - competent and consequent. Forget other courses. Stay here, you won't regret. Kudos to CS Dojo.
@keerthanaanandan60625 жыл бұрын
Def comment1(): print("thanks for teaching me") print("thanks once again") Comment1()
@rickydawn63134 жыл бұрын
Input Error missing Positional input
@allipse82244 жыл бұрын
@@puchu_5001 same
@oussematoussli80854 жыл бұрын
Comment 1() should be comment1() not with the Capital letter
@jinsonthekkan74204 жыл бұрын
D should be also small letter
@KS_Harshith4 жыл бұрын
def comment1(): print("thanks for teaching me") print("thanks once again") print(comment1()) # this is the correct code
@legal8276 жыл бұрын
I absolutely love your videos. My father inspired me to learn programming, as in the past I’ve learned some but I’ve gathered a lot of laziness towards programming because of a lot of heavy school work. My father encourages me to just read the documentation and learn Python piece by piece, but I find that boring and hard to follow. Your videos keep me going and they are professional and clear. Instead of buying courses on Udemy, I just use your courses and they’re amazing. Thank you so much.
@Toxicbeing87503 ай бұрын
how are you now doing you must be a guru now
@tradeviper8745 жыл бұрын
Well, out of all of the different, gazillion sites and videos I have paid for and not paid for, you are, in the 61 yr olds opinion, The Best. Knowing what you are doing, and Teaching, are two different skill sets. In my business, just because you have intellect and mental ability, does not mean you will make money. You are doing quite well, starting with a base concept, then giving a practical example, then breaking it down to show how it works. Outstanding job, young man just outstanding. Also, Kudos on your English, bring multilingual myself, it can be a daunting task at times, but you have also done well here. Keep up the good work and I look forward to seeing your future success, by the way, maybe a paid forum might help keep a roof over your head? :) The Ever Kudoing VIPER
@zumzumwater30185 жыл бұрын
Hey Trade, My dad is 65, and his typing speed is 11wpm, anything below 30 is considered very slow. How do I get my dad to stop acting like such an old man?
@rickydawn63134 жыл бұрын
@@zumzumwater3018 Viagra gives you wings.
@PeterLucasathome4 жыл бұрын
@Trade Viper, I endorse your comments. At 71, I am learning to code thanks to this young man. He is doing an excellent job. Last time I did any coding was back in the 80's, when if you couldn't write a little BASIC, you couldn't get a computer to do anything. @CS Dojo , you deserve success!
@HHTP63 жыл бұрын
dont worry grandpa this video alone can get 15 months of rent
@AnonymousXvictoriouS3 жыл бұрын
@@zumzumwater3018 he is an old man
@shahin23243 жыл бұрын
My Professor thinks he's the real shit in Python by creating videos that are 5 hours long just to explain one concept!!!! Now, this is called a real teaching video!!!! short and informative!!!
@elkresurgence3 жыл бұрын
maybe your prof really delved into that concept during those five hours. Short isn't always good, although in the case of this tutorial it is
@joeroganpodfantasy422 жыл бұрын
Maybe if your professor would release his videos on youtube people would appreciate them more. I have noticed people tend to dislike what it's offered to them locally or thru a system and they like what they find themselves online.
@t345m7 ай бұрын
At least yours tries my professor gives us half examples and then stops teaching 30 mins in. The class is supposed to be 3 hours! Be happy that he actually cares, unlike mine.
@evelyn-ed7nn2 жыл бұрын
I think what is insane is that these videos were made in 2018 and I'm sitting here on the same program in 2022 and it still looks the same, still works the same, it's just so easy to use; it's incredible.
@abdulkhadir44982 жыл бұрын
For those who want to write a quadratic equation, I wrote a code and felt I should share this. So here is the code: def function2(x): a=2 b=3 c=4 return a*(x**2)+b*x+c value_of_my_equation=function2(-2.2) print(value_of_my_equation) Note: you can assign any value for x inside the parentheses beside value_of_my_equation=function2 and any values to a,b,c.
@elmo8905 жыл бұрын
miles = int(input()) def convert(miles): print("KM:") return miles*1.6 km = convert(miles) print(km) Asks to type in miles when run, converts input to KM. Or remove int(input()) and set miles = "amount of miles"
@KokkuBhanuprakash4 жыл бұрын
excellent bro😱😱😱😱
@guiantony2 жыл бұрын
miles = int(input()) def convert(miles): print("KM:", end="") return miles*1.6 km = convert(miles) print(km) (with it stays in the same line :) )
@epiccownerdfighter2 жыл бұрын
I know this is an old vid I'm commenting on, but you earned an instant sub (well, after 3 videos). Informative, understandable, well presented, quick. Great stuff for a beginner like me!
@emmanuelpierre8856 Жыл бұрын
Hey YK, I from Canada, Québec, Gatineau and I speak french more than english. I am an absolute beginners on python (leaning how to code). I want to let you know that all your Python tutorial are well explained and I love following your courses cause you take your time to explain step by step and I found this a great quality and skills you have. Keep continue what you do, teaching us, sharing your knowledge and more. Your great energy will bring you where ever you want and you will get what ever you need to accomplish your goals. 👍
@lovathon6365 Жыл бұрын
I've been self studying using another website where I bought a course on sale, and I have been struggling so much with functions that I even stopped for 2-3 weeks because I just felt so dumb that I couldn't grasp what was being asked of me... this video broke it down so nicely that after so long I'm finally able to grasp what was being said all along. thank you for making this video, it has brought me back to coding!!
@TheNewTravel4 жыл бұрын
I was hoping you would go back and add the "is" before "not overweight', it was driving me crazy haha. Great video :)
@phamgiaminh64964 жыл бұрын
You are learning Python, too? =))
@ivanreyes77703 жыл бұрын
Tks i already do it
@PNCNDNOB3 жыл бұрын
haha same here.. i did it on my end tho.. lol
@oskarwitha_k82583 жыл бұрын
Wdym, he did change it
@devonchin945 жыл бұрын
def convert(miles): return miles*1.6 km = convert(int(input("Enter miles here: "))) print(str(km) + " km") I decided to take it one step further with the challenge. Allow a user input to convert miles to km, and convert that integer to a string to show the km after the value! Thanks so much for these videos! I am absolutely loving learning python3 (my first programming language). And having passionate people recording tutorials like this really helps more than I could ever put into words!
@rakotai99985 жыл бұрын
honestly i did the same thing the reason i took a step further was cuz the actual challange was too easy and tried to make a user type the miles and it convertes it to km and i was bout to paste the code in here but guess I was slow. LMAO you got me.
@vasileafloarei2516 жыл бұрын
def functie_km(km): return 1.6 * km print("conversis km in mile") a = functie_km(4) print(a)
@pranithsukhavasi25024 жыл бұрын
return 0.6*km(correction)
@am_sf65744 жыл бұрын
@@pranithsukhavasi2502 it's not 0.6 though
@Dark_dragon12126 ай бұрын
why not just do def convert(miles): print("converted km in miles") return 1.6*miles convert(4) I assume conversis is a synonym for convert or converted.
@dansmith9406 Жыл бұрын
5 years later and this video is still amazing! You just helped a total noob complete part of the cs50 course with this video. I had no idea how to do mapping with a function. Perfect explanation. Thank you
@nzehemmanuel37742 жыл бұрын
I’m Emmanuel from Ghana and I was thinking about how to start my semester Computer programming. I didn’t know what to do but from the fews videos I have been watching from your site . I very motivated to do this course. Thank you soo much for giving me this foundation 🙏🙏
@milittt4 жыл бұрын
The best part: Running a code without error 😑😑😑
@AQ-1013 жыл бұрын
@Loai Alghamdi yes 😁
@am_sf65744 жыл бұрын
Def convert(x): Return x * 1.6 + " km" Km = convert(5) #5 miles Print Km
@khytron063 жыл бұрын
And you can also ask the user for an input : def convert(x): print(x*1.6+"km") a=int(input("Distance(miles): ")) convert(a)
@builder4813 жыл бұрын
def convert(m): return m * 1.6 km = convert(8) print(km) I also made this it convert feet to cm def hight(length): return length * 30.48 tallinCm = hight(6.4) print(tallinCm)
@Rinaa966 Жыл бұрын
My solution ^^ def convert(mile): km = mile * 1.60934 return str(mile) + " mile is equal to " + str(km) + " km"
@rafnael8807 Жыл бұрын
just add the print(convert(x)) statement
@pharmacist2576 Жыл бұрын
@@rafnael8807 what about: def miles_km_converter(km, miles): km = 1.6 * miles print("km ") print(km) miles = 5 miles_km_converter(km, miles)
@joemorris65443 жыл бұрын
I have been following along with Python Crash Course book in my spare time and anytime I get stuck on a problem or don’t quite understand what I’m doing I always come to your channel. This video helped me understand functions a lot more.
@AAsisters843 жыл бұрын
After searching on KZbin for 30 minutes, This video was the only one that really helped me understand how to use the functions. Thx a lot.
@kennethchin2784 жыл бұрын
I thought the overview of functions was excellent. Covering what one can use functions for, quickly and concisely, ( be it mappings and returning calculations. ) as well as using of strings. Much appreciate. I've watched a few online Python vidoes and it's nowhere near as sysynced and easy to understand with useful examples as yours. Keep up the good work.
@droidzz49356 жыл бұрын
Here is the function: def convert(miles): km = 1.6 * miles print("km: ") print(km)
@zz-nj1bq4 жыл бұрын
ok
@ThErrandBoy4 жыл бұрын
@akash anil he's not wrong, you just have to call the function cos he didn't assign it to a variable (since he used print and not return.) and he should have said km = 1.6/miles not 1.6*miles.
@michaelegiebor5244 жыл бұрын
Should have used return argument instead
@rahmats.89134 жыл бұрын
it's not a function
@droidzz49354 жыл бұрын
@@rahmats.8913 ?
@agamgujral56964 жыл бұрын
I did: def km(x): return (1.6 * x) Miles = km(20) print(miles) 32
@khalanesachin4 жыл бұрын
Yours is also right but you managed it little differently than he asked .. What he is expecting (in my opinion) is as follows... def convert(miles): return miles*1.6 km = convert(100) print(km) 160.0 Which means 100 miles= 160km
@TollpatschZ1234 жыл бұрын
@@khalanesachin Yeah makes more sense that way. Thanks for sharing.
@LaxmiGupta-cl2go4 жыл бұрын
def miles(x): return 1.6*x y= miles (45) print ('y=', y, 'km') y= 72.0 km ( I prefer it with unit, hence) Your teaching is really good. Thanks YK!
@saganmcvander6365 жыл бұрын
@CS_Dojo Wow you actually explain functions properly unlike the thousands of 30 minute youtube videos that never explain any of this properly.
@orthodox82246 жыл бұрын
def convert(miles): print(1.6*miles) miles = int(input("Enter miles :")) convert(miles)
@brasoveanuionut32073 жыл бұрын
And what if i input 10.7 ? Answer : Not working, Xd
@shashiverma62196 жыл бұрын
Love from India bro..I learned PHP year ago ..and at that time I was keen to learn python..but didn't happened.. I did 2 months job as PHP developer in a small company..I left..coz i thought it's not that's I want..but after watching ur another videos and that python series..I think I can do this..thanks for uploading the videos ..and keep uploading bro..thank you so much brother.
@diogo83866 жыл бұрын
Hey man, how many time you took to learn php and to get the job?
@OsadeTOOT6 жыл бұрын
i thought you said "love you indian bro" lol
@paulovinicius58335 жыл бұрын
Best functions classes I've ever seen. Congrats!
@geniushalo54734 жыл бұрын
You mean "Thanks"?
@RealSpyduh4 жыл бұрын
@@geniushalo5473 ahahahahah yeah i think thats what he meant XD
@geniushalo54734 жыл бұрын
@@RealSpyduh Yeah xd. Its kinda wierd to congratulate someonw
@delubiod19703 жыл бұрын
@@geniushalo5473 We Brazilians Congratulate everyone who does that extra mile when teaching. He deserves to be Congratulated. Don't you think? Teaching is hard. When someone teaches a topic so easy, just thanking him will sound like an understatement to his effort, I guess....
@HipsterBrooo Жыл бұрын
Bro I feel like I've browsed through a gazillion videos on Functions and only this video helped me. THANKS A TON😭
@fryaadil16872 жыл бұрын
Just started learning Python as a hobby. I have no programming experience but I am really enjoying it so far. Thanks, man. Your teaching method is really good.
@xmisteralex4 жыл бұрын
I did: def convert(miles): return 1.609*miles km=convert(150) print("km =",km) km = 241.35
@swallowedinthesea114 жыл бұрын
Nice! 06302020
@lzcracker6 жыл бұрын
This is the most clear, concise explanation of python I've found, thank you so much for the hard work. :)
@siddhijha8946 жыл бұрын
YK 😁😍 thank u and keep working over it ,u r an awesome teacher 😂
@ankixsounds6 жыл бұрын
Siddhi Jha hi
@aakilahmed86496 жыл бұрын
an awesome teacher tho
@ryz3nplayz3644 жыл бұрын
no not awesome... ITS THE BEST teacher
@MrMikeIppo5 жыл бұрын
Sir, you are the most helpful teacher I have found online: def CS_Dojo(): print("instant Like") print("instant Subscribe")
@joseph51664 жыл бұрын
I love that you can see even a simple function can be performed in all sorts of different ways from the comments here. Here's what I got: def convert_miles_to_km(miles): km = 1.6 * miles print(miles, "miles is equivalent to", km, "kilometers.")
@Chucky55255 жыл бұрын
My miles to kilometer converter: def convert(miles): return 1.6 * miles def temp(x): return 1 * x a = convert(4) x = 4 print(x) print(a) print(x, "miles is", a, "km")
@richardd55874 жыл бұрын
Really good series. Thought I'd dip into Python as it's the language used in my nephew's school and he will be taking Computer Science next year. As a retired Science teacher with a lot of experience coding in VB and VBA I've found the presentations very clear and rarely miss a trick (like the importance of the number of leader spaces!). Although I was using PyCharm I now think the Jupyter IDE has the edge for younger students.
@noflare17144 жыл бұрын
You cannot imagine the amount of joy I felt when I converted km to miles😂😂😂😂
@chernobylcoleslaw66984 жыл бұрын
Nah I scream for joy when I nail some code; even if it is basic af.
@celineangelina26973 жыл бұрын
howw? can you post it here?
@ShreyasV03 жыл бұрын
@@celineangelina2697 def convert(miles): print(1.6*miles) miles = int(input("Enter miles :")) convert(miles)
@MinotaurvsCyclops3 жыл бұрын
@@celineangelina2697 KM to MILES (my way): def convert(miles): km = miles / 1.6 print(f"This is the amount in miles {km}") miles = float(input("Enter KM here: ")) convert(miles)
@eleenasen42903 жыл бұрын
@@chernobylcoleslaw6698 OMG same I was like YASSS IM NOT DUMB lolol
@MAFABI-g7e Жыл бұрын
These tutorials for YK are making me to improve day and night on python
@supersoniq41022 жыл бұрын
I was having a tough time understanding Functions from my other teachers since i'm new to .py. In Less than a Minute you've made it seem like ABC. You are a genius!!
@shree27106 жыл бұрын
Its like waiting for the new episode of your favourite anime, only the difference is that you dont know when the new episode is gonna be dropped.
@Ahmedcoday6 жыл бұрын
loooool
@rakotai99985 жыл бұрын
LMAO! i am currently watching Kenja no maga , Kimitsu no yoba , fairy tale: final season and thats all
@77shaiksultan5 жыл бұрын
You can't compare anime with this
@kennyg19535 жыл бұрын
Idk man I've been waiting for Naruto Ep 501 for a while.
@Red-yq6nc5 жыл бұрын
@@@kennyg1953 Fam naruto is over, now they have a half assed series named boruto which is basically like naruto filler but its cannon
@tyres95 жыл бұрын
def convert(mile): km = 1.6 * mile return str(mile)+ " miles is " + str(km) + " kms" a = convert(float(input("input distance in miles: "))) print(a)
@pilgrim2734 жыл бұрын
print('hello yk') name = tom print(name) print('here and i want to thank you for the videos you create which are much better than how my teachers teach at school'')
@sultanmahamud7134 Жыл бұрын
You just helped me with something i was stucked for long
@martijnvangelder190210 ай бұрын
Thanks bro, your calm demeanor made me understood functions immediately. I'm a guy studying chemistry, and have to take a class in python. I hope I pass, and if I do, it'll be because of your videos.
@PNCNDNOB3 жыл бұрын
learning so much here, i am going to get a official course on Pyhton (because i have to do some studies or work from the government here in the Netherlands), so i think that is going to be way easier now.. thanks a lot! as soon as i get a job again i am donating some money to you bro!!
@xodiaki4 жыл бұрын
my solution: miles = int(input("Enter the amount of miles you'd like to convert :")) def convert(miles): return miles * 1.6 km=convert(miles) print(km) kms=int(input("enter the amount of kms you'd like to convert :")) def convet_km(kms): return kms/1.6 mile=convet_km(kms) print(mile)
@rinovichaz31684 жыл бұрын
If you convert your input as float instead of int it will be more accurate i think. I tried ur code using the input of 100.99999 an the conversion was a little off... using a float instead of an integer will not ignore decimals and therefore will give you the most accurate result. But ur code helped me out a little so thanks
@xodiaki4 жыл бұрын
@@rinovichaz3168 you're welcome and yes float will work better !
@Strawhaty4 жыл бұрын
@@xodiaki surely your code would work without the miles? why use them??
@xodiaki4 жыл бұрын
@@Strawhaty what do u mean lol
@adzefeabdulraman6526 жыл бұрын
I have been missing a lot.I just subscribed to your channel yesterday. I'm enjoying it.God bless you
@dukhtarakhtar2 жыл бұрын
I tried after taking your 2 classes nd boom feeling like an expert btw it's my 1st programming language that I'm learning
@harshp25774 жыл бұрын
I've watched this video like 5 times trying to understand why the bmi code works the way it does. Finally got it
@shubhamkawade3174 жыл бұрын
so it's dec 2019, i know i'am late, but you saved me. thank you so much!
@allridio5 жыл бұрын
Def convert(miles) Km = 1.6*miles Print(miles) Return km M=convert(any value) Print(M)
@xxss97ssxx4 жыл бұрын
mil = input("Enter miles: ") miles = float(mil) def convert(miles): km = 1.6 * miles return km conversion = convert(miles) print(conversion)
@alokpatnaik6924 жыл бұрын
1 mile = 1.6 km So 1 km = 1 mile/1.6
@KrolPower4 жыл бұрын
You can also combine your first two lines to simplify and organize a bit better. Ex: miles = float(input("Enter miles:")) That way you don't have an extra variable to keep track of.
@elantris-20024 жыл бұрын
@@KrolPower I did it like this lol xD x = 1.6 def c1 (x, y): return 1.6*y and print (1.6*y)
@KrolPower4 жыл бұрын
@@elantris-2002 lmao
@elantris-20024 жыл бұрын
@@KrolPower but it works 😂
@goodnessgideon89602 жыл бұрын
wasn't understanding but later got a hang of it, cs dojo is the best coding tutor thanks
@tasneemalshamsi18523 жыл бұрын
U don't even know how much this helped me .. I couldn't get the idea of this def thing until I saw ur vid and I'm so thankful that God leaded me to u .. seriously THANK U
@evelynwang48184 жыл бұрын
wow i learned more in the first 3 vids than i did taking a four week summer camp python course. thank you so much ! im in eighth grade and this understandable even for beginners.
@QazDiaries4 жыл бұрын
Def convert(miles): print (miles, "miles is", km, "kilometres") return 1.6 * miles km = convert(miles) convert(2) print(km) 2 miles is 3.2 kilometres
@KokkuBhanuprakash4 жыл бұрын
that's wrong bro
@KokkuBhanuprakash4 жыл бұрын
u typed "D"instead "d"
@tamejamu75224 жыл бұрын
showing name miles is not defined
@centerofmotivation19044 жыл бұрын
Here's the code I made for the conversion of miles to km's: loop = "Y" def conversion(miles): kilometers = miles * 1.609345 return kilometers while loop == "Y": try: miless = float(input("What are the miles you are trying to convert to kilometers?: ")) print(conversion(miless)) loop = input("Would you like to convert another number Y or N?: ").upper() except ValueError: print("That is not a valid input") print("It was nice converting numbers with you see you some other time.")
@mukhtarabdi87312 жыл бұрын
Thanks Sir for your introductory course to Python. I am a novice in python but have R prgoramming background. You made the whole learning process easy. here is the exercise which I have tried: # Write a function that converts 100 miles to km def conv_miles_km(miles): km = miles * 1.6 print('100 miles is equal to {}'.format(km)) # return km # call the function conv_miles_km(100) 100 miles is equal to 160.0
@TatTvamAsi1734 жыл бұрын
def convert(x): return 1.6 * x x = int(input("Enter the dist in miles: ")) e = convert(x) print(f"The dist is {e} km")
@oleksandrherasymenko31676 жыл бұрын
So love your "Ahhhhh" stuff.
@Tait19905 жыл бұрын
def convert(miles): km = 1.6 * miles return km converting_miles_to_km = convert(3) print (converting_miles_to_km)
@diemausdietastatur87385 жыл бұрын
well after 4 months :D but id say this is better def convert(miles): return miles * 1.6 print(convert(4))
@elmo8905 жыл бұрын
@@diemausdietastatur8738 This is the way I did it, you input miles and it converts the input to KM. #Miles to KM miles = int(input()) def convert(miles): print("KM:") return miles*1.6 print(miles) km = convert(miles) print(km)
@elmo8905 жыл бұрын
Or: miles = int(input()) def convert(miles): amount = 1.6 print("KM:") return(amount * miles) km = convert(miles) print(km)
@hashpants80346 жыл бұрын
Could you please explain RETURN in more detail please.
@swallowedinthesea116 жыл бұрын
Return value gets stored and saved into a variable. def addSum(num, num2): return num + num2 answer = addSum(500, 100) # answer = return 500 + 100 # answer = return 600 # variable answer is now equal to the return value 600.
@koconutto6 жыл бұрын
I Didnt understand return very good
@WhoForgot2Flush6 жыл бұрын
If anyone still needs helps, just think of a return as the value of the function. For instance at the end when he writes... km = convert(miles) you know the "convert" function will need to return something, can be an integer or a string or anything, because you are storing the returned value of the function to a variable. If you did not have a return in the convert method you would not be able to store it to a variable. Inside this function would be... return 1.6 * miles if you didn't put the return there it would still execute the code but you would not be able to say km = convert(mile) since the function would not be returning anything.
@KlimYadrintsev6 жыл бұрын
Mike Naples thanks
@KlimYadrintsev6 жыл бұрын
11swallowedinthesea thanks
@bartkornacki35903 жыл бұрын
CS Dojo you put things into the plain explanation-something that the other tutorials lack
@shudanhao86432 жыл бұрын
Thank you so much. i am a new learner of python, the return and function are really confusing for me. This video perfectly explained them for me. Keep up the good work!!!
@Akuphakpa6 жыл бұрын
Finally i got this video. I has been waiting from your last video(if else statement )thank you so much yk ..
@sagnik03974 жыл бұрын
miles=int(input("Enter distance to miles: ")) def conversion(): km=1.6*miles return km print("Distance in kilometres is ",end="") print(conversion()) #lemme know if I am correct or any way to improve the code.
@simeonnenov34993 жыл бұрын
miles=int(input("Enter distance to miles: ")) Instead of int, you can put float, so that the code does not crash when someone enters a number with a "." Like 100.2
@sagnik03973 жыл бұрын
@@simeonnenov3499 yeahhh thanks a lot for helping
@AntiagingVideos4 жыл бұрын
Hi dojo and thank you for the great tutorial. When you say "a function is a collection of structures". What is a structure? Thank you!
@logantucker183510 ай бұрын
Watching this at the gym. Way more helpful than the class I’m taking
@scorpiomischief4 жыл бұрын
I have been on app after app and watched tutorial after tutorial, but this is the first video I've seen that explained things clearly and directly using simple terms I could understand. I'm going to be a subscriber of yours forever now! You definitely have a gift for teaching. So many folks in computer science (even if they're brilliant coders) have difficulty explaining their process in a concise way. So thank you; you're a life saver! I'm going to go turn off my adblock now and re-watch this in gratitude :)
@TrueMathSquare6 жыл бұрын
Thanks this is great.
@TheHyrossl4 жыл бұрын
Here is my solution: def convert_km(miles): return 1.6*(miles) def convert_miles(km): return km / 1.6 x = convert_km(20) y = convert_miles(10) print(x) print(y)
@examupdates39774 жыл бұрын
Great
@charliepickford85544 жыл бұрын
What I did was: milesinput = 13 def converter(miles): return (miles * 1.6) d = converter(milesinput) print(milesinput, "miles =", d, "km")
@sippincay4 жыл бұрын
i did km = 5 def convert(miles): print(“miles: “) print(km * 1.6) result1 = convert(miles)
@Kemachris4 жыл бұрын
'''very clean i like it! Mine is a bit clunky and only goes one way, but atleast i made it take user input :p ''' miles = int(input("How many miles would you like to convert to KM's? ")) def km(miles): km = miles * 1.6 print((round(km,2,)), end="", flush=True) print(" KM's") km(miles)
@drdre19644 жыл бұрын
Here's mine. def convert(miles): print(miles," miles is ",miles*1.6," kilometers") def convert2(km): print(km," kilometers is ",km/1.6," miles") a=convert(100) b=convert2(160)
@72prabhatkumar916 жыл бұрын
Sir i am big fan u......i have watched your all video....thanx
@gabrielmoreno30276 жыл бұрын
PRABHAT KUMAR now watch some english tutorials, thank you.
@peyushbht79826 жыл бұрын
lmao
@ajithsdevadiga16035 жыл бұрын
@@gabrielmoreno3027 as if you are from Oxford 🤣🤣
@gabrielmoreno30275 жыл бұрын
@@ajithsdevadiga1603 Oxford = English??? XDDD are you kidding me
@kingsleyosuala14232 жыл бұрын
Thank you so much CS Dojo, I have learned a lot from your tutorials. did the assignment, that converts miles to kilometer and also from kilometer to miles. I went further to ask the user for input. unit = str(input('What do you want to convert? Enter m for miles or k for kilometer: ')) distance = eval(input('Enter distance: ')) km = 1.6 * distance miles = distance / 1.6 def convert(): if unit == "m": return km elif unit == "k": return miles result = convert() if unit == "m": print(distance, "miles is equal to: ", result, "km") elif unit == "k": print(distance, "kilometer is equal to: ", result, "miles") else: print("Invalid unit or distance; enter m for miles or k for a kilometer and enter distance as a numeric value")
@avikghosh51124 жыл бұрын
my answer: def convert(miles) return 1.6 * miles km = convert (10) print(km) 160. thanks CSdojo!
@briangrey48495 жыл бұрын
bmi_calculator(name, height_m, weight_kg): bmi = weight_kg / ( height_m**2) so here arguments/variables are name, height_m, weight_kg and name1, height_m1, weight_kg1 are different than name, height_m, weight_kg then when return result, how bmi knows that it has to do weight_kg1 / ( height_m1**2). i think it should only work for weight_kg, and height_m values as that values are in function and in bmi formula. weight_kg1 ,height_m1 are totally different values than weight_kg, height_m then how it works ?
@albertoavena5 жыл бұрын
brian grey I have the exact same question and I'm been trying to figure it out for 2 days now! Where is name, height_m and weight_kg getting the values from if the three people you defined have different names??
@maamooon79105 жыл бұрын
well im not the only one through 😂
@jaydebbhunia36765 жыл бұрын
hey, Change the name of def value (name, height_m, weight_kg) to (a, b, c) still it will work - because that is the condition which is assigned to def function
@michaelmartinez84705 жыл бұрын
name, height_m, weight_kg are parameters that live inside the function bmi_calculator, used to calculate the bmi. you can think of them as "this" and "that" and "alsothis" or "a", "b", "c" or "x", "y", "z". they're just arguments; the function uses "three things". it calculates bmi by using (c divided by b**2 (or b squared)) and returns "name" or "this" or "a" or "x" + a printed string. it also "returns" a new value bmi but does so by printing it as a string, so it might be confusing. bmi still lives within the function. "result1 = bmi_caculator(name1, height_m1, weight_kg1)" is like saying "call the function bmi_calculator (which accepts three parameters), and execute it and assign to variable result1". it assigns result1 by plugging three arguments or parameters into the function. in result1's case its plugging in "YK" for name in bmi_calculator(name, height_m, weight_kg), "2" for height_m in bmi_calculator(name, height_m, weight_kg), and "90" for weight_kg in bmi_calculator(name, height_m, weight_kg). the confusion is probably coming from the parameter names being named similarly to the variable names. name1 could have been a variable t = "YK" and height_m1 could have been u = "2" and weight_kg1 could have been v = "90" and it could have been "result1 = bmi_calculator(t, u, v)" and it would have worked exactly the same.
@nathanst-laurent85836 жыл бұрын
NameError Traceback (most recent call last) in () ----> 1 result1 = bmi_calculator(name1, height_m1, weight_kg1) 2 result2 = bmi_calculator(name2, height_m2, weight_kg2) 3 result3 = bmi_calculator(name3, height_m3, weight_kg3) what do I do?
@user_z114 жыл бұрын
yeah same
@user_z114 жыл бұрын
ok this comment is 2 year old did you get it
@George-pt2ot4 жыл бұрын
@@user_z11 lol
@anemawbishaw28273 жыл бұрын
It's harder than i thought 😨
@siyandavilakazi7814 ай бұрын
That's what she said
@paulmulderry37884 жыл бұрын
Thanks for taking the the time to explain syntax in python tutorials. I find your approach to teaching encouraging.
@sagharxatami66483 жыл бұрын
I'm in love with your explanation. everything was obvious and understandable, but one point to those who actually code the same thing in their editor, if you run the program and don't get the result, try to read it one by one like python does and also pay attention, that if you actually haven't mentioned the value of your parameter in your function. After all, python won't understand if you use or call it in your function because everything you type in function is counted as the function's work so try to check out to make sure you didn't make that mistake and to make sure, you can basically look at your code to see the spaces and if there are 4 spaces where you mentioned the function it means you have called it in a function and to solve that problem you can go ahead and delete those spaces to begin from the beginning of the line. hope u understand me well.
@simantoahmed98494 жыл бұрын
I still don't understand that "return" string. Once called in function it appears but when calling BMI calculator, it doesn't appear until result1,2,3
@raves_r31774 жыл бұрын
the bmi calculation is already printed inside the function.The return does not print in the terminal unless printed in the main code. It's just like calling a built in function x = upper("hello"), you dont leave it like that because it does not print itself. you have to print it using print(x).
@arjunjain874 жыл бұрын
Because by using the return function we are 'returning' or 'assigning' the value to result1,2,3 or any other variable, it is just like, a = 5, so u will get 5 when u print(a) instead of when calling the function. Hope this helps. . . .
@rubikulelerubiksandukulele46075 жыл бұрын
Is my code correct? When I run it, I got 32 :-) def mile(km): return 1.6*km print (mile(20))
@Xous_4 жыл бұрын
Miley Blutatu no it’s a = mile(20) print(a)
@ToshDeCamerz4 жыл бұрын
@@Xous_ mileys code is much more efficient and writing a=.... Is unnecessary
@Cmog8844 жыл бұрын
I feel like I can remake skyrim
@rdenel71263 жыл бұрын
killleeed me xDDDDDD I FELT LIKE I COULD FIX CYBERPUNK GLITCHES
@levnikitin74323 жыл бұрын
@@rdenel7126 damn i think even for world's most infamous coders fixing cyberpunk would be difficult
@cybernerd74923 жыл бұрын
Yes
@matmattarayao12773 жыл бұрын
@@cybernerd7492 sup cyberfucked
@cybernerd74923 жыл бұрын
@@matmattarayao1277 sup dog😎
@jieweikwan5 жыл бұрын
Hello YK! Just wanted to say I hardly had any interests in other videos - eg from Coursera as they were usually not straight to the point. But your videos keep me going n the step by step allows me to imprint the steps into my head! I think this is really important for someone who can’t listens to Long lectures and am really thankful to have found your video 🥺
@noorfatima16424 жыл бұрын
Miles = input("enter in miles ") Mil = float(miles) Def km(m) : Print ("distance in kilometres is ") Return 1.6 * m Result = km(mil) Print(result) This take the input from the user So so happy 😁
@valdemarcarl55014 жыл бұрын
I have an ongoing course on Python basics. The user defined functions are discussed in two lessons: kzbin.info/www/bejne/rafPg3x3hZmjjMk kzbin.info/www/bejne/in_aY6qgabR8g9U The complete playlist of ongoing Python basics is: kzbin.info/aero/PLWF9TXck7O_wMDB-VriREZ6EvwkWLNB7q
@saiyamnahata85106 жыл бұрын
14:30 1 mile = 1.6km and not the reverse
@OriginalEch3Official6 жыл бұрын
you jusr said what he said dumbass
@InsaneI6 жыл бұрын
4:25 I hope they werent executed. I dont like seeing lines being killed
@atiyanimmi72434 жыл бұрын
im dead 😂😂😭
@thejackgoldenbergsho5 жыл бұрын
Hi, I am not that knowledgeable, but in minute 9:30 in this #3 Functions video, it is not clear why when you run the program a second time and call the function, the number 12 appears as a calculation but without the other two print commands.... WHY NOT?
@liquidsunsets1943 жыл бұрын
if you run the function it will print the first two print commands but for the last return command its evaluating some value and return it as an output .. in order to print that value you have to assign it to a variable and then print it ... if you try to do these steps with a function that has no return command you’ll get (none) as in no output bcs you didnt include it in the function I hope this makes any sense but think of it as having a calculated value that you want to print but first need to assign a variable to it ^ ^
@jeremyeltoro46937 ай бұрын
km= float(input("insert amount in Kilometers: ")) def miles(x): return x / 1.6 e=miles(km) print(e, "miles")
@alexisdelgado87373 жыл бұрын
THANK YOU I am taking a machine learning course this fall and I currently am learning python still and you explain so well i am learning so fast