CS50P - Lecture 1 - Conditionals

preview_player
Показать описание

TABLE OF CONTENTS

00:00:00 - Introduction
00:00:24 - Conditionals
00:02:47 - if
00:09:56 - elif
00:15:06 - else
00:18:30 - or
00:22:06 - Not Equal
00:24:17 - Indentation, Colons
00:25:13 - and
00:28:48 - Chaining Comparison Operators
00:32:20 - Bugs
00:34:16 - Modulo
00:40:00 - Boolean
00:44:10 - Pythonic Expressions
00:48:15 - match
00:55:41 - Conclusion

An introduction to programming using a language called Python. Learn how to read and write code as well as how to test and "debug" it. Designed for students with or without prior programming experience who'd like to learn Python specifically. Learn about functions, arguments, and return values (oh my!); variables and types; conditionals and Boolean expressions; and loops. Learn how to handle exceptions, find and fix bugs, and write unit tests; use third-party libraries; validate and extract data with regular expressions; model real-world entities with classes, objects, methods, and properties; and read and write files. Hands-on opportunities for lots of practice. Exercises inspired by real-world programming problems. No software required except for a web browser, or you can write code on your own PC or Mac.

Whereas CS50x itself focuses on computer science more generally as well as programming with C, Python, SQL, and JavaScript, this course, aka CS50P, is entirely focused on programming with Python. You can take CS50P before CS50x, during CS50x, or after CS50x. But for an introduction to computer science itself, you should still take CS50x!

***

HOW TO SUBSCRIBE

HOW TO TAKE CS50

HOW TO JOIN CS50 COMMUNITIES

HOW TO FOLLOW DAVID J. MALAN

***

CS50 SHOP

***

LICENSE

CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License

David J. Malan
Рекомендации по теме
Комментарии
Автор

YouTube isn’t social media… it’s a vital resource!!!

paul-d-mann
Автор

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.

cleidysbrooks
Автор

Thank u David. Your teaching style makes programming very easy.

umair
Автор

Officially my favorite show now! Enjoying every episode. Awesome production, genius cast.

mariyayurchenko
Автор

I would only say:



Name = input("who is the best python teacher? ")


If name== "David j. Mallam":
Print("correct answer")

Else:
Print("incorrect answer")

janmohammad
Автор

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)

jsonkody
Автор

I' m in awe with the way David teach! Respect

timothyfidelis
Автор

the best python teacher i came across my python learning journey... sir you are legend tutor

Girish-Navani
Автор

Best Teacher is the world, hands down!!!!

OmariEtetembaWilondja
Автор

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 <80:
print("Grade: C")
elif score <90:
print("Grade: B")
else:
print("Grade: A")

But then again I suppose this is less readable in a sense that if is opposite of our normally expected direction of counting down.

Mathadder
Автор

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

kylofps
Автор

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.

lakshmiprabhakarkoppolu
Автор

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

mohammedsafiahmed
Автор

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 )

Thesoccerguy
Автор

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 😄

kylofps
Автор

it is amazng how i did not even noticedd that it was going on and such a smooth lecture: i have never come across.

ishatariq
Автор

Thank You David Sir, Greetings from India

Monte
Автор

YouTube is not s social media 😊❤

it's emotion bcoz of David

ken
Автор

can you please make a couse on java and c++?that would be so helpful

farhanishraq
Автор

That pause at 42:29 made everything sink in so bad

bebitoomar