Incredible how David teaches with excellent knowledge. It does it in such a way that you understand what you are doing. Thank you for teaching in such an excellent and emotional way David. You're the best.
I am 14 years and can understand it preety well accept the problem set need to see it 10 times to understand (can't they write it down in simple english )
23:25 .. you can use "Alt + up/down" to shift the whole line up or down ;) very convenient, very fast Of course you may just hold Alt and keep pressing down down down down ... etc. then get another line and shift it up (it also work for multiple lines if you highlight them)
Bruh he knows it probably as he has a lot of experience but he is using it as it might be complex for us to understand and he will have to introduce next topic making it more complicated
I would only say: Name = input("who is the best python teacher? ") If name== "David j. Mallam": Print("correct answer") Else: Print("incorrect answer")
34:01 I don't know if "less than" is more efficient than "less than or equal to" since it's only checking one thing instead of two, but if it is, you could check in reverse and remove the "equal to" like so. if score < 60: print("Grade: F") elif score < 70: print("Grade: D") elif score
48:00 In Python 3, there is no maximum value for an int. It can store arbitrarily large numbers, limited only by the available memory on your system. This is a change from Python 2, where int had a maximum value of 2**31 - 1 (approximately 2 billion) on a 32-bit platform and 2**63 - 1 (approximately 9 quadrillion) on a 64-bit platform.
43:20 I assume she meant once we define a fucntion, can we use it as a method, so can you use your own function , lets say func(), on some object, like object.func(). I dont think so. You'll have to define a class for that
Hi. 41:21 He defined two functions i.e. main() and is_even() but called main() function only. Why doesn't he call the second function? Isn't that necessary?
@@knowledgeseeker2452 hello there! He only called the main function because that’s what he wanted to execute. If you see in the definition on main function, the third line called the is even function. ( if is_even(x): So by calling the main function, he is indirectly calling the is even function as well
33:40 Just an idea, but what if we split it up into 2 groups to reduce the amount of "questions" that we are asking? Something like this: if score >= 80: if score >= 90: print("Grade: A") else: print("Grade: B") else: if score >= 70: print("Grade: C") elif score >= 60: print("Grade: D") else: print("Grade: F") Not sure if this makes the program any more efficient, but it seems like it could reduce the average amount of questions we ask the program because, for example, if the score was an F, normally we check: is it an A? B? C? D? Oh it's an F. But for this we would check: is it a B or better? C or better? D or better? Oh it's an F. Of course that would mean it adds another question we are asking the program if the score is an A, because we have to check if it's a B or better first, but yeah. Let me know if this makes any sense 😄
I think the original most efficient version was if score>=90: elif score>=80 elif score>=70 elif score>=60 else 4 max questions, and you have 4 questions too in ur code, how did ur version reduce the number of questions asked. I didn't get it
for 90+ ur code asks 2 questions, the original asks 1; for 80-90 score the original asks 2 questions, your code asks 2 and so on... if anything i think ur version is asking more questions in some cases
I am 14 years and can understand it preety well accept the problem set need to see it 10 times to understand (can't they write it down in simple english )
About the pythonic expressions, I just figured out something could be simplified to print("Even" if int(input("What's x? ")) % 2 == 0 else "Odd") yeah, I realize it might not be as readable but I just thought it was cool lol
41:21 He defined two functions i.e. main() and is_even() but called main() function only. Why doesn't he call the second function? Isn't that necessary?
print("What is the answer to the Great Question of Life, the Universe and Everything?") user_input = input("").strip().lower() match user_input: case "42" | "forty two" | "forty-two" : print("Yes") case _: print("No") print(user_input )
At 39:14 he said if this function returns true then program will print even. So is he saying that returning true will satisfy the formula or something else. Please help me
Dear David, I love your classes, the way you teach is 5 stars. I have a question. Could we use match instead of elif in the exercise grade? Ps. I wanted to study at Harvard because of your classes. :)
At 41:59 Question with the function. Why on line 3 does he put an x in the () but on line 9 he puts a n in the ()? I don't really get the whole argument thing with a function.
The x in line 3 is referring to the input of "def main()" and the n in line 9 refers to "any" number in the context of the new definition "def is_even()". IF you would use an x in both definitions, the programme would still run correctly because both x are nested inside different def-functions. But for the sake of clarity, David used an "n" which is often use to refer to ANY number. Thus, IF the n of "def is_even(n)" returns TRUE to "if is_even(x)" inside of "def main()" --> then "Even" is going to be printed.
@@blackgrizzly4987 question please: I wrote the exact code but I couldn't call main() TypeError: main() missing 1 required positional arguments: 'x' Is what I get everytime, and even if I add x in main() NameError: name 'x' is not defined Is what I get .. . Do you please have any idea how to fix this error?
I am a totally beginner at coding. I really want to know what kind of courses I can take to get a job as a programmer without a CS diploma? Or is it possible to get a job like this without a degree?
you can get a cs job without a cs degree but getting your first job might be hard, if you have enough experience and projects in your resume you're good to go.
if a != b: print("a is not equal to b") else: print("a is equal to b") This works just fine. Maybe this was what the guy wanted to know, if something like this will work (without indentation).
54:15 I don't recall pipes ( *|* ) being ever mentioned on this course, *Why* exactly were they used instead of simply adding an *OR* operator between each of the gryffindor names?
I think he was just adding it in to show that there are multiple ways to get the same answer. It just comes down to personal preference and how you want your code to look.
@@searcherror4463 it would have been nice if he had first explained what they are and why he used them instead, while I know what they meant even back then, others could not understand them
Is this an even better understanding? by just converting integer to boolean, as most other program understand 0 value as False and 1 as True. So,Can I just >>> def is_odd(rt): >>> return bool(int(rt % 2)) ???
Hi was wondering if anyone knows if match case. Does not work on all python services yet like Codecademy and pycharm ? As there is no automatic indentation or even when I put it in i receive a syntax error
Could anybody tell me why or in what scenario i would rather use the match/case method instead of the if method? From what i understand from the video it's more readable when you have a definitvie set of values but is there anyother usage where the match method is better suited than the if one? / sory for bad english, it's not my mothertounge.
the "match" type is not working for me. instead it is throwing syntax error, i tried and tried and copied it that way. but is not working, anybody with any idea?
in 42:20 how the python knows that if it is true it should print even and if it is false it should print odd coz i modified the program by replacing false in the place of true and true in the place of false can anyone clear this doubt plss the program: def iseven(n): if n%2==0: return False else: return True
indentations tells the compiler that after a statement whatever is indented is part of that statement, for example if you noticed whatever david writes after defining main at start is actually indented but when he is defining a new functions he removes the indentation for def statement.
you will get that will practice, when to indent and when not to. Simply put, you indent whenever some lines of code are a part of a condition, a loop, a function, or a class. Whatever you write indented under a function definition ( def function():), that code will be a part of that function, and will execute whenever that function is called. Likewise, whatever code is indented under a conditional will only be executed if the condition is true, same goes for a loop. Indention is a way to tell the compiler what part of the entire code is part if function / loop / if, and what isnt.
Normally you have indent when a statement ends with a colon like IF or defining a function or class, about how indentation works: # both this comment and the next # statement are on indentation "lv 0" Def something(): # this is on indentation lv 1 # everything that belongs to this # function will START at lv 1 # now we have a if inside the func If a == b: # now this is indentation lv 2 # since it's inside a if inside a # function If c == d: # this is indent lv 3 #this is lv 2 #this is lv 1 #this is lv 0 You have to determine what belongs to what, lv 1 belongs to the "something" func (including the if) lv 2 belongs to the if inside the function, lv 3 belongs to the if inside the if and lv 0 belongs the the "program" , hopefully yt doesn't wrap the lines and ruin everything ._.
Hello everyone I was hoping someone could help me with something in the meal problem of problem set 1 I'm running with some problems def main(): time = input("What time is it: ") convert(time) if 7.0
You have this error because the condition is working with the time input rather than the return value from the convert function. To fix this, you need to create a variant that gets the return value from your convey function and use that to check in your time conditions … times = convert(time) … if 7.0
He is wrong about that is_even function cannot be done in Java or C++, the way final version was shown in Python. Below is C++ version, which has curly braces, but code inside the function is identical to Python. bool is_even(int n){ return n%2 == 0; }
He didn't mean returning just the boolean, he meant the ternary operator. And yes, there is a ternary operator in other C-languages, but most have the syntax: expr ? True : False as in C++ or Java. In Python it is another syntax as in the video: True if expr else False which might be syntactically easier to understand because it reads more like natural english than the ternary in most other languages. All he meant was that the syntax differs.
The simplest code you wrote (3d one) for grading has a problem. If we will enter anything above 100 for example 999, it will still give gread A in output so better we write an if statement at starting...
#spare fat finger typing # Parity.py code for modulo segment of CS50 lecture 1 # Verbose Comments provided by Copilot AI Pair programmer def main(): # main function to call other functions and print results # lecture 1 x = int(input("What is X? ")) # ask user for input if is_even(x): # if x is even, print this print("X is even") else: # if x is odd, print this print("X is odd") def is_even(n): if n % 2 == 0: # if n is even, return True return True # even else: # n % 2 != 0 return False # if n is not even, return False main() # call the main function
This is what TH-cam is made for!
Absolutely Agree 🫡
Yup❤️
TRUE ;)
would be if hasnt been made by google
@@KarolKasperek It wasn't, actually! It was bought out by Google.
TH-cam isn’t social media… it’s a vital resource!!!
Here, here!
PREACH!
True that brother
@ YT has its problems, serious ones, but it’s still the last subscription I’d let go.
Incredible how David teaches with excellent knowledge. It does it in such a way that you understand what you are doing. Thank you for teaching in such an excellent and emotional way David. You're the best.
I am 14 years and can understand it preety well accept the problem set need to see it 10 times to understand (can't they write it down in simple english )
Thank u David. Your teaching style makes programming very easy.
As a newbie I find it hard to remember all this
@@mjsmcd Just do daily practice. The more you code (practice) these concepts the more you know them. Practice Practice Practice
@@mjsmcd there's no need to remember just understand the logic
I' m in awe with the way David teach! Respect
the best python teacher i came across my python learning journey... sir you are legend tutor
Officially my favorite show now! Enjoying every episode. Awesome production, genius cast.
23:25 .. you can use "Alt + up/down" to shift the whole line up or down ;)
very convenient, very fast
Of course you may just hold Alt and keep pressing down down down down ... etc. then get another line and shift it up (it also work for multiple lines if you highlight them)
Bruh he knows it probably as he has a lot of experience but he is using it as it might be complex for us to understand and he will have to introduce next topic making it more complicated
thnaks
@@Sureshpaudel1 he probably left the comment for the viewers
thank you
Best Teacher is the world, hands down!!!!
CS50 is emotion
I would only say:
Name = input("who is the best python teacher? ")
If name== "David j. Mallam":
Print("correct answer")
Else:
Print("incorrect answer")
Ахаахахах)
thats malan, your code is wrong either way
@@iraiseddonut congrats bro you won
name = input("who is the best python teacher?
")
match name:
case: "David J. Mallan"
print("correct answer")
case_:
print("incorrect answer")
34:01 I don't know if "less than" is more efficient than "less than or equal to" since it's only checking one thing instead of two, but if it is, you could check in reverse and remove the "equal to" like so.
if score < 60:
print("Grade: F")
elif score < 70:
print("Grade: D")
elif score
48:00
In Python 3, there is no maximum value for an int. It can store arbitrarily large numbers, limited only by the available memory on your system. This is a change from Python 2, where int had a maximum value of 2**31 - 1 (approximately 2 billion) on a 32-bit platform and 2**63 - 1 (approximately 9 quadrillion) on a 64-bit platform.
Yo, this course was seriously lit! 🔥 Learned so much, highly recommend! 💯📚
The quality of the content is impressive!
43:20 I assume she meant once we define a fucntion, can we use it as a method, so can you use your own function , lets say func(), on some object, like object.func(). I dont think so. You'll have to define a class for that
Hi.
41:21 He defined two functions i.e. main() and is_even() but called main() function only. Why doesn't he call the second function? Isn't that necessary?
@@knowledgeseeker2452 hello there!
He only called the main function because that’s what he wanted to execute. If you see in the definition on main function, the third line called the is even function. ( if is_even(x):
So by calling the main function, he is indirectly calling the is even function as well
33:40
Just an idea, but what if we split it up into 2 groups to reduce the amount of "questions" that we are asking?
Something like this:
if score >= 80:
if score >= 90:
print("Grade: A")
else:
print("Grade: B")
else:
if score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")
Not sure if this makes the program any more efficient, but it seems like it could reduce the average amount of questions we ask the program because, for example, if the score was an F, normally we check: is it an A? B? C? D? Oh it's an F. But for this we would check: is it a B or better? C or better? D or better? Oh it's an F.
Of course that would mean it adds another question we are asking the program if the score is an A, because we have to check if it's a B or better first, but yeah.
Let me know if this makes any sense 😄
That's ok but the length of program still remains same,so doesn't make it any better
I think the original most efficient version was
if score>=90:
elif score>=80
elif score>=70
elif score>=60
else
4 max questions, and you have 4 questions too in ur code, how did ur version reduce the number of questions asked. I didn't get it
for 90+ ur code asks 2 questions, the original asks 1; for 80-90 score the original asks 2 questions, your code asks 2 and so on... if anything i think ur version is asking more questions in some cases
but nice thinking never the less, the idea is to understand the inner workings of the code and strive towards more efficient coding.
I am 14 years and can understand it preety well accept the problem set need to see it 10 times to understand (can't they write it down in simple english )
it is amazng how i did not even noticedd that it was going on and such a smooth lecture: i have never come across.
thank u david for giving me such wonderful Python lessons ❤❤
Awesome course once again! I would love to see the course with data science in python in the future!
Thank You David Sir, Greetings from India
About the pythonic expressions, I just figured out something could be simplified to
print("Even" if int(input("What's x? ")) % 2 == 0 else "Odd")
yeah, I realize it might not be as readable but I just thought it was cool lol
oh my g! it's cool af
Nice!
TH-cam is not s social media 😊❤
it's emotion bcoz of David
He is a great teacher 🙏🌹
Thanks for this series! Turbo epic stuff!
lecture done #4/4/23. 10 more to go!
done yet?
Done yet?
Day 1: 25:19
Day 2: 56:07
i love the way he teach its amazing
can you please make a couse on java and c++?that would be so helpful
Intro to programming,he write code in C I think
thank you very much proff , your explaining is much good
That pause at 42:29 made everything sink in so bad
The best of the best= David Malan
30:10 I've never seen that '0' already excited for this course
Omg that match is like that "copy the homework but don't make it identical" meme, why isn't there a "default" but a "case _:" eww
I wonder why he didn't show the "if b in [a, b, c] syntax, maybe he's gonna show it in the array video
Great class! thanks!
41:21 He defined two functions i.e. main() and is_even() but called main() function only. Why doesn't he call the second function? Isn't that necessary?
because the is_even function is inside the main function, and calling main already calls the is_even fucntion(IG so)
print("What is the answer to the Great Question of Life, the Universe and Everything?")
user_input = input("").strip().lower()
match user_input:
case "42" | "forty two" | "forty-two" :
print("Yes")
case _:
print("No")
print(user_input
)
too good method of teaching
Great Stuff. Thank you
completed!
5:15 PM
25 July 2024
What an interesting guy! thank you man!
One year later finally finished lecture 1
Im in awe to your level of procastination
At 39:14 he said if this function returns true then program will print even. So is he saying that returning true will satisfy the formula or something else. Please help me
if is_even: basically means if the function "is_even" is true (if the number is even, then it is true)
@@mohammedfouzan9115 Thanks man ❤️
Dear David, I love your classes, the way you teach is 5 stars. I have a question. Could we use match instead of elif in the exercise grade? Ps. I wanted to study at Harvard because of your classes. :)
At 41:59
Question with the function. Why on line 3 does he put an x in the () but on line 9 he puts a n in the ()? I don't really get the whole argument thing with a function.
The x in line 3 is referring to the input of "def main()" and the n in line 9 refers to "any" number in the context of the new definition "def is_even()".
IF you would use an x in both definitions, the programme would still run correctly because both x are nested inside different def-functions. But for the sake of clarity, David used an "n" which is often use to refer to ANY number.
Thus, IF the n of "def is_even(n)" returns TRUE to "if is_even(x)" inside of "def main()" --> then "Even" is going to be printed.
@@blackgrizzly4987 question please:
I wrote the exact code but I couldn't call main()
TypeError: main() missing 1 required positional arguments: 'x'
Is what I get everytime, and even if I add x in main()
NameError: name 'x' is not defined
Is what I get .. .
Do you please have any idea how to fix this error?
Did you watch lecture 0? He mentioned exactly that...
@@emmasong7366 you probably put a x inside the parentheses in "def main ()"
@@blackgrizzly4987 Thank you! I scrolled for a while looking for someone who asked this question / answer. You rock!
day 4 27:13 coming back later today to finish the video 36:02
I am a totally beginner at coding. I really want to know what kind of courses I can take to get a job as a programmer without a CS diploma? Or is it possible to get a job like this without a degree?
many many people get computer programming jobs with only 6 months experience, while also being self taught
@@Bennyrule Is there any website for programmers to share experiences so that a beginner can learn how to start?
@@rick9773 th-cam.com/video/79pKwdiqcwI/w-d-xo.html
I think this video will clear your doubt(if you still have that is)
you can get a cs job without a cs degree but getting your first job might be hard, if you have enough experience and projects in your resume you're good to go.
if a != b: print("a is not equal to b")
else: print("a is equal to b")
This works just fine. Maybe this was what the guy wanted to know, if something like this will work (without indentation).
Without intendation we can't do
54:15 I don't recall pipes ( *|* ) being ever mentioned on this course,
*Why* exactly were they used instead of simply adding an *OR* operator between each of the gryffindor names?
I think he was just adding it in to show that there are multiple ways to get the same answer. It just comes down to personal preference and how you want your code to look.
@@searcherror4463 it would have been nice if he had first explained what they are and why he used them instead, while I know what they meant even back then, others could not understand them
At 39:51, the code works exactly the same way even if you omit the "else: return false" part. Why is that? Can someone explain to me?
I think it is because even if you don’t add that bit, in the main part, it will still print odd if is_even does not come out to be true
thanks David
53:00 How can we add lower () method to these strings? I want the right result if the user types mixing upper and lower case.
Thank you
12:48 Can i see this as entry level algorithm?
Gosh, I finally understand the logic behind Return. Smh....
In the first code, are the first 2 lines just text or actually a variable? pls clarify
It prompts the user to put in a value for x and y. The values are not hard coded
Is this an even better understanding? by just converting integer to boolean, as most other program understand 0 value as False and 1 as True. So,Can I just >>> def is_odd(rt): >>> return bool(int(rt % 2)) ???
yeah you can, good idea
but then again you are making it a bit complex, feel like return rt%2==0 is short and sweer
How I can get four dots using tab like david ?
Just click on "Tab"
@@huginn3007 I know this.
But, I want that four dots also.
I want to create a Turkish subtitle for this video. How can I do so ?
Keep it up
Hi was wondering if anyone knows if match case. Does not work on all python services yet like Codecademy and pycharm ? As there is no automatic indentation or even when I put it in i receive a syntax error
Could anybody tell me why or in what scenario i would rather use the match/case method instead of the if method? From what i understand from the video it's more readable when you have a definitvie set of values but is there anyother usage where the match method is better suited than the if one? / sory for bad english, it's not my mothertounge.
for personal use 40:54
I think i laughed way more at that "who?" Than i should.....
amazing
the "match" type is not working for me. instead it is throwing syntax error, i tried and tried and copied it that way. but is not working, anybody with any idea?
Be sure to use Python 3.10!
52:07 does match cange to be switch?
Hi David, iam a totally beginner ,I don't understand where to start programming. Will you help me?
It's the best thing
Hi i have a syntax problem idk why, im trying to do the "Grade" exercise at 27:00, when i try to do "if score >= 90 and
already see the error, i forgot write score after "and"
You don't know how many times I've made that mistake when i first started
I want to know how he got his VS code to look like that. I cant start new files from terminal i just get an error that i dont understand
This only happens in Linux not in windows
@@saifullahacda1109 kinda. he’s using a custom codespace that runs Linux I got some help in the discord and got it to work
@@saifullahacda1109no if you type code correct.py it works
in 42:20 how the python knows that if it is true it should print even and if it is false it should print odd
coz i modified the program by replacing false in the place of true and true in the place of false
can anyone clear this doubt plss the program: def iseven(n):
if n%2==0:
return False
else:
return True
That's based upon ur users condition 😅
lecture 2 done
0:34:53
anyone watching this lets get in touch and learn together
Hi how far ahead are u?
I'm watching
most of doubt person from INDIA
what?
عاااااااش
25:59
how do you know where to use the indentation?
I believe when you ask a question and need to print a statement in answer to the question, the print function would be indented
indentations tells the compiler that after a statement whatever is indented is part of that statement, for example if you noticed whatever david writes after defining main at start is actually indented but when he is defining a new functions he removes the indentation for def statement.
you will get that will practice, when to indent and when not to. Simply put, you indent whenever some lines of code are a part of a condition, a loop, a function, or a class.
Whatever you write indented under a function definition ( def function():), that code will be a part of that function, and will execute whenever that function is called. Likewise, whatever code is indented under a conditional will only be executed if the condition is true, same goes for a loop.
Indention is a way to tell the compiler what part of the entire code is part if function / loop / if, and what isnt.
Normally you have indent when a statement ends with a colon like IF or defining a function or class, about how indentation works:
# both this comment and the next
# statement are on indentation "lv 0"
Def something():
# this is on indentation lv 1
# everything that belongs to this
# function will START at lv 1
# now we have a if inside the func
If a == b:
# now this is indentation lv 2
# since it's inside a if inside a
# function
If c == d:
# this is indent lv 3
#this is lv 2
#this is lv 1
#this is lv 0
You have to determine what belongs to what, lv 1 belongs to the "something" func (including the if) lv 2 belongs to the if inside the function, lv 3 belongs to the if inside the if and lv 0 belongs the the "program" , hopefully yt doesn't wrap the lines and ruin everything ._.
@@sayori3939 thank you
❤️❤️
I want to be the one of puppet sitting there xD
Yeah i wanna disguise as one :3
match name :
^
SyntaxError: invalid syntax
Do anyone have solution?
Try to run code on python version 3.10 above so that this new match feature work. Otherwise if your python version less than 3.10 it will not work.
@@lockborethdevid3533 oh thanks for letting me know. I was using 3.9
@@lockborethdevid3533 I am on 3.11.9 and it does not work =( it looks like python do not recognize %
@@lockborethdevid3533 nevermind, I found the problem xD I F UP in the terminal! Shoul have cleaned it before running the program
feeding the algorithm
Hello everyone I was hoping someone could help me with something
in the meal problem of problem set 1 I'm running with some problems
def main():
time = input("What time is it: ")
convert(time)
if 7.0
You have this error because the condition is working with the time input rather than the return value from the convert function.
To fix this, you need to create a variant that gets the return value from your convey function and use that to check in your time conditions
… times = convert(time)
… if 7.0
32:48 saving it and saying downside instead hahahaha
Hello, but was this course filmed?
Hi is streaming this is record today
25:41
48:21
42:00
16:29
25:13
thanks
i love you
He is wrong about that is_even function cannot be done in Java or C++, the way final version was shown in Python. Below is C++ version, which has curly braces, but code inside the function is identical to Python.
bool is_even(int n){
return n%2 == 0;
}
He didn't mean returning just the boolean, he meant the ternary operator. And yes, there is a ternary operator in other C-languages, but most have the syntax: expr ? True : False as in C++ or Java. In Python it is another syntax as in the video: True if expr else False which might be syntactically easier to understand because it reads more like natural english than the ternary in most other languages. All he meant was that the syntax differs.
The simplest code you wrote (3d one) for grading has a problem. If we will enter anything above 100 for example 999, it will still give gread A in output so better we write an if statement at starting...
8:13
#spare fat finger typing
# Parity.py code for modulo segment of CS50 lecture 1
# Verbose Comments provided by Copilot AI Pair programmer
def main(): # main function to call other functions and print results # lecture 1
x = int(input("What is X? ")) # ask user for input
if is_even(x): # if x is even, print this
print("X is even")
else: # if x is odd, print this
print("X is odd")
def is_even(n):
if n % 2 == 0: # if n is even, return True
return True # even
else: # n % 2 != 0
return False # if n is not even, return False
main() # call the main function
6:32 i think i'm good
Mr. Malan you are so handsome
this comment checks
200th comment