Python Cheat Sheet - Mosh Hamedani.pdf
(
2385 KB
)
Pobierz
Python
Cheat Sheet
Mosh Hamedani
Code with Mosh (codewithmosh.com)
1st Edition
About this Cheat Sheet
This cheat sheet includes the materials I’ve covered in my Python tutorial for
Beginners on YouTube. Both the YouTube tutorial and this cheat cover the core
language constructs but they are not complete by any means.
If you want to learn everything Python has to offer and become a Python expert,
check out my Complete Python Programming Course:
http://bit.ly/complete-python-course
About the Author
Hi! My name is Mosh Hamedani. I’m a software engineer
with two decades of experience and I’ve taught over three
million how to code or how to become a professional
software engineer. It’s my mission to make software
engineering simple and accessible to everyone.
https://codewithmosh.com
https://youtube.com/user/programmingwithmosh
https://twitter.com/moshhamedani
https://facebook.com/programmingwithmosh/
Variables .................................................................................................. 5
Comments ................................................................................................. 5
Receiving Input ........................................................................................5
Strings ......................................................................................................6
Arithmetic Operations .............................................................................7
If Statements ............................................................................................8
Comparison operators ............................................................................ 8
While loops ............................................................................................... 8
For loops ...................................................................................................9
Lists ........................................................................................................... 9
Tuples ........................................................................................................9
Dictionaries.............................................................................................10
Functions .................................................................................................10
Exceptions................................................................................................ 11
Classes...................................................................................................... 11
Inheritance .............................................................................................12
Modules ................................................................................................... 12
Packages ..................................................................................................13
Python Standard Library ......................................................................13
Pypi .........................................................................................................14
Want to Become a Python Expert? ........................................................ 14
Variables
We use variables to temporarily store data in computer’s memory.
price =
10
rating =
4.9
course_name =
‘Python for Beginners’
is_published =
True
In the above example,
•
price
is an
integer
(a whole number without a decimal point)
•
rating
is a
float
(a number with a decimal point)
•
course_name
is a
string
(a sequence of characters)
•
is_published
is a
boolean.
Boolean values can be True or False.
Comments
We use comments to add notes to our code. Good comments explain the hows and
whys, not what the code does. That should be reflected in the code itself. Use
comments to add reminders to yourself or other developers, or also explain your
assumptions and the reasons you’ve written code in a certain way.
# This is a comment and it won’t get executed.
# Our comments can be multiple lines.
Receiving Input
We can receive input from the user by calling the
input()
function.
birth_year =
int(input(‘Birth
year: ‘))
The
input()
function always returns data as a string. So, we’re converting the
result into an integer by calling the built-in
int()
function.
Plik z chomika:
handehoch
Inne pliki z tego folderu:
DIVA 5 ADHD wersja PL.pdf
(1212 KB)
Wyborowa przepisy na drinki.pdf
(4830 KB)
Jak zadbać o włosy wysokoporowate.pdf
(13707 KB)
Python Cheat Sheet - Mosh Hamedani.pdf
(2385 KB)
Perfect Pairings.docx
(82 KB)
Inne foldery tego chomika:
2% Theory 4 in 1
Ebooki
Ebooki bez hasła
Ebooki nowości 3.02
Filmy
Zgłoś jeśli
naruszono regulamin