background preloader

Python Cheat Sheet

Python Cheat Sheet
String String Methods Array Indexes and Slices a=[0,1,2,3,4,5] 6 len(a) 0 a[0] 5 a[5] 5 a[-1] 4 a[-2] [1,2,3,4,5] a[1:] [0,1,2,3,4] a[:5] [0,1,2,3] a[:-2] [1,2] a[1:3] [1,2,3,4] a[1:-1] Shallow copy of a b=a[:] Math Constants math.pi The mathematical constant π = 3.141592..., to available precision. math.e The mathematical constant e = 2.718281..., to available precision. Random Functions Sys Sys Variables argv Command line args builtin_module_names Linked C modules byteorder Native byte order check_-interval Signal check frequency exec_prefix Root directory executable Name of executable exitfunc Exit function name modules Loaded modules path Search path platform Current platform stdin, stdout, stderr File objects for I/O version_info Python version info winver Version number sys.argv foo.py sys.argv[0] bar sys.argv[1] -c sys.argv[2] qux sys.argv[3] --h sys.argv[4] os Variables Class Special Methods String Formatting Formatting Operations 'd' Signed integer decimal. Date Formatting Date Formatting Ad Related:  Algorithme

Création d'applications mobiles : 8 tutoriels vidéo pour les débutants ! - Geek Junior - Programmer une appli mobile ? Facile avec les tutos vidéo de Teen-Code ! Geek Junior te propose en partenariat avec Teen-Code de t’initier à la création d’applications mobiles (sous Android), avec une série de tutoriels que tu as retrouvés toutes les 2 semaines sur notre site jusqu’à Noël. Ca y est ! En attendant la prochaine qui démarrera début 2017, voici une synthèse de tout ce que tu auras appris une fois les 8 tutos faits et tes 8 applis créées. Tu auras fait un grand pas dans l’apprentissage de la programmation, sans même t’en rendre compte ! Tuto 1 Hello World : Comment créer une application dans App Inventor, comment la tester et comment l’installer sur son téléphone ou sur sa tabletteComment concevoir l’interface utilisateur de l’application, puis programmer son comportement dans l’interface BlocksComposants faire parler le téléphone, et lui faire faire des actions en le secouant Tuto 2 Graffiti : Tuto 3 Traqueur : Tuto 4 Zombie Mash : Tuto 5 Piano : Tuto 6 Maths Attack !

pyglet Installing Python on Windows First, download the latest version of Python 2.7 from the official Website. If you want to be sure you are installing a fully up-to-date version, click the Downloads > Windows link from the home page of the Python.org web site . The Windows version is provided as an MSI package. By design, Python installs to a directory with the version number embedded, e.g. Typing the full path name for a Python interpreter each time quickly gets tedious, so add the directories for your default Python version to the PATH. C:\Python27\;C:\Python27\Scripts\ You can do this easily by running the following in powershell: [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User") The second (Scripts) directory receives command files when certain packages are installed, so it is a very useful addition. Setuptools + Pip To obtain the latest version of Setuptools for Windows, run the Python script available here: ez_setup.py Virtual Environments

Keep This Python Cheat Sheet On Hand When Learning To Code Python is one of the best programming languages to learn. As you get started, this one-page reference sheet of variables, methods and formatting options could come in handy. Provided by Dave Child, the cheat sheet includes both built-in system and operating system variables, as well as standard methods for working with lists, files and strings. You can download it for free in PDF or PNG version or view it online at the link below. Python Cheat Sheet [AddedBytes]

Hopscotch - Make your own game. Learn to code. Dolibarr - ERP CRM et Open Source - Portail France Beat Detection Algorithms - Math and Physics Disclaimer This document is to be distributed for free and without any modification from its original state. The author declines all responsibility in the damage this document or any of the things you will do with it might do to anyone or to anything. This document and any of its contents is not copyrighted and is free of all rights, you may thus use it, modify it or destroy it without breaking any international law. However according to the author's will, you may not use this document for commercial profit directly, but you may use indirectly its intellectual contents; in which case I would be pleased to receive a mail of notice or even thanks. This is my first tutorial and I am still a student, you must assume that this document is probably not free of small errors and bugs. Introduction Simulating a physical phenomena which obeys to known mathematical equations is, with a number of approximations, always feasable. I – Statistical streaming beat detection 1 – Simple sound energy

Python bad practice, a concrete case | Julien Danjou A lot of people read up on good Python practice, and there's plenty of information about that on the Internet. Many tips are included in the book I wrote this year, The Hacker's Guide to Python. Today I'd like to show a concrete case of code that I don't consider being the state of the art. In my last article where I talked about my new project Gnocchi, I wrote about how I tested, hacked and then ditched whisper out. Before I start, please don't get the spirit of this article wrong. The first thing that I noticed when trying to hack on whisper, is the lack of test. $ coverage run test_whisper.py........... While one would think that 61% is "not so bad", taking a quick peak at the actual test code shows that the tests are incomplete. When I tried to modify whisper, as the tests do not check the entire cycle of the values fed into the database, I ended up doing wrong changes but had the tests still pass. The code doesn't respect PEP 8 . That piece of code could be easily rewritten as:

OverAPI.com | Collecting all the cheat sheets

Related: