r/learnprogramming • • Apr 06 '18

Awesome Python Cheat Sheet

Here is a great cheat sheet for Python by Laurent Pointal (whoever you are). Thanks a ton! :)

If you like this sheet, maybe you are interested in our own cheat sheet course consisting of 5 cheat sheets (keywords, basic and complex data structures, object orientation, and tricks).

1.6k Upvotes

53 comments sorted by

27

u/paradox_hunter Apr 06 '18

This is brilliant! Is there a similar resource for C as well?

46

u/CowboyBoats Apr 06 '18

Check out learnXinYminutes; they have C and C++.

18

u/IAmAHat_AMAA Apr 06 '18 edited Apr 06 '18

The copy of K&R I borrowed from the library for my intro to algorithms subject had this cheat sheet folded up in it and it was honestly the single most useful resource for that subject.

https://users.ece.utexas.edu/~adnan/c-refcard.pdf

1

u/koayenay Apr 06 '18

Did u find anything for c++?

Thanks in advance!

1

u/wrong_assumption Apr 07 '18

Something like that for Go would be awesome.

6

u/Xeverous Apr 06 '18

C can have already a lot, especially pointer arithmetics and arrays + implicit convertions. Just imagine how many cheat sheets you could make for C++

1

u/Righteous_Dude Apr 06 '18

There's a company called "BarCharts" that makes "Quick Study" laminated pages for various topics.

See these search results.

51

u/Gobi_The_Mansoe Apr 06 '18

As of python 3.6 you can also use f strings instead of .format. So instead of "This text is variable: {}".format(variable) you can just use f"This text is variable: {variable}" . I find it much easier to keep track of what is going on.

9

u/bicyclepumpinator Apr 06 '18

whoah, I had no clue. Awesome feature which I'll surely use in the future, thanks!

3

u/agrzw Apr 07 '18

I've waited for this sugar for a long time, .format() syntax always looked a little bit ugly as for me, when you have prepared variables for formatting.

115

u/Righteous_Dude Apr 06 '18 edited Apr 06 '18

A warning for anyone who plans to print that two-page PDF:

(1) The first time I printed it, the colored text came out as very light gray which was illegible. On my second try, I updated my print settings to "Print all text as black". The colored text then came out as medium-gray which was legible (although still lighter than I'd like).

(2) The printed copy seems to be too small - on an 8.5"x11" page, it only appeared as about 6.5"x9". On my third try, I updated my print settings to increase to 125% size. The printed version then properly filled the page.
(Edit to add: I just realized that my browser's print settings had been to print at 70% size,
so my need to increase to 125% was maybe specific to me.)

16

u/[deleted] Apr 06 '18

Thank you!!

10

u/phoenix4208 Apr 06 '18

Your printer toner might be low, it printed fine for me.

13

u/DeliciousKiwi Apr 07 '18 edited Apr 07 '18

This isn't quite a cheat sheet because it's 26 pages, but it has similar formatting and I've found myself going back to it quite often. Definitely worth checking out:

Beginner's Python Cheat Sheet.

Also, original source: https://ehmatthes.github.io/pcc/cheatsheets/README.html

3

u/CrispyJoe Apr 07 '18

This chart sheet is a lot more comprehensive. Thanks so much!

1

u/ThisIsMyLastAccount Apr 07 '18

For noobs like me this is fucking perfect.

10

u/[deleted] Apr 06 '18

I have minicopies of these cheatsheets under my glass desk.

It's like I am literally cheating at job.

3

u/acousticpants Apr 07 '18

cool use of a glass desk!

1

u/AkshayD110 Apr 10 '18

This makes me go for a glass desk !

14

u/LemonsForLimeaid Apr 06 '18

As someone trying the the into to comp sci using python on edX, please excuse the stupid question. I know it says for Python 3 up top, but can I use this for python 3.5 as well?

10

u/Womblr Apr 06 '18

Yep

4

u/LemonsForLimeaid Apr 06 '18

thanks a bunch!

2

u/[deleted] Apr 06 '18

It's Python 2 and 3 that are noticeably different from one another.

2

u/woja111 Apr 06 '18

There's a big leap between Python 2 and 3. Python 3.x are more improvements but not groundbreaking.

2

u/mihirmusprime Apr 06 '18

I disagree. While it's been introduced recently, ordered dictionaries are definitely groundbreaking.

7

u/Denarb Apr 06 '18

Thanks a bunch, as someone who uses python every once in while this is awesome for remembering syntax!

3

u/[deleted] Apr 06 '18

This is why i love reddit

3

u/fixkotkplease Apr 06 '18

I would love one of these for java! Anyone got one? : )

1

u/itskush_maaan Apr 06 '18

Awesome and props to Laurent Pointal

3

u/[deleted] Apr 06 '18

Laurent 4 president!

2

u/[deleted] Apr 06 '18

This is great, thanks for sharing.

2

u/[deleted] Apr 06 '18

great resource.

2

u/smash_bang_fusion Apr 06 '18

Looks like he does CS research in france! https://perso.limsi.fr/pointal/

2

u/wtf1968 Apr 06 '18

Cheat sheets are awesome, this one is great too. Adding it to my collection.

1

u/DatabaseDev Apr 06 '18

Care to share the others

1

u/koayenay Apr 06 '18

I also want the others.

2

u/Hyedwtditpm Apr 07 '18

There is a new Awesome Python Cheat Sheet like every few minutes.

2

u/Sledik Apr 07 '18

Amazing! Thank you very much!

2

u/AkshayD110 Apr 10 '18

Opening a file for reading or writing should always be done using "with". That ways f.close() (closing of file) is taken care with in .

1

u/koayenay Apr 06 '18

I need something like this for c++.

1

u/nikkarus Apr 07 '18

This is excellent. Thank you!

1

u/heun3344 Apr 07 '18

I saved it. Thank you

1

u/Fajkowsky Apr 07 '18

Thanks! Is anyone know there something like this for JS/ES6/ES7?

1

u/vincezz2005 Aug 02 '18

This is very helpful. Thanks!

0

u/[deleted] Apr 06 '18

[deleted]

4

u/Righteous_Dude Apr 06 '18 edited Apr 06 '18

There's a company called "BarCharts" that makes "Quick Study" laminated pages for various topics.

See these search results.


By the way, one of the pages found by that search was this long page at princeton.edu which had a link to this 30-page PDF about typical compile and runtime errors in Java, which looks like it would be helpful to those learning Java.

2

u/DearSergio Apr 06 '18

That's pretty cool!

1

u/darthvalar Apr 06 '18

Commenting so I can refer back to this java resource if given.