background preloader

How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 2nd Edition documentation

How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 2nd Edition documentation
Navigation How to Think Like a Computer Scientist¶ Learning with Python¶ 2nd Edition (Using Python 2.x) by Jeffrey Elkner, Allen B. Last Updated: 21 April 2012 Copyright NoticeForewordPrefaceContributor ListChapter 1 The way of the programChapter 2 Variables, expressions, and statementsChapter 3 FunctionsChapter 4 ConditionalsChapter 5 Fruitful functionsChapter 6 IterationChapter 7 StringsChapter 8 Case Study: CatchChapter 9 ListsChapter 10 Modules and filesChapter 11 Recursion and exceptionsChapter 12 DictionariesChapter 13 Classes and objectsChapter 14 Classes and functionsChapter 15 Classes and methodsChapter 16 Sets of ObjectsChapter 17 InheritanceChapter 18 Linked ListsChapter 19 StacksChapter 20 QueuesChapter 21 TreesAppendix A DebuggingAppendix B GASPAppendix c Configuring Ubuntu for Python DevelopmentAppendix D Customizing and Contributing to the BookGNU Free Document License Search Page © Copyright 2010, Jeffrey Elkner, Allen B. Related:  Startup LearningPythonPython-abilia

Benefits of this Interactive Textbook — How to Think like a Computer Scientist: Interactive Edition This interactive book is a product of the Runestone Interactive Project at Luther College, led by Brad Miller and David Ranum. There have been many contributors to the project. Our thanks especially to the following: This book is based on the Original work by: Jeffrey Elkner, Allen B. The Runestone Interactive tools are open source and we encourage you to contact us, or grab a copy from GitHub if you would like to use them to write your own resources.

5 Ways To Learn Code From Your Own Browser One of the big trends of the past couple years, spurred the growing demand for programmers, is the rise of in-browser programming tutorials. Gone are the days when you’d have to buy a book and configure a development environment before you could get your hands dirty with a little code. Maybe you want to start learning on your work computer and don’t have access to install a programming environment. Or maybe you want to get started right away and don’t want to deal with ordering books or installing software. 1. Eloquent JavaScript is actually a computer science book but it’s available on the web for free. 2. We’ve covered Codecademy and its mission to bring code literacy to the masses several times before. 3. Last week the Khan Academy revamped its computer science section to include a set of in-browser JavaScript tutorials. 4. Code School‘ offers a mix of free and paid in-browser courses, many of which are aimed at more accomplished programmers. 5. Bonus 1: Programr Bonus 2: Try Ruby

Typ-Umwandlung (Datentypkonvertierung) | Python – Newbie Zuvor hatten wir versucht 2 Strings zu addieren und sind daran gescheitert. Es wurde nicht das erwartete Ergebnis der Addition ausgegeben, sondern beide eingegebenen Werte wurden zu einem zusammen „gezogen“. Ausgangsbasis war Das Programm verbessern Man kann bei einer „Addition“ von Strings nicht erwarten, dass man eine Zahl als Ergebnis erhält. Wenn man die Variablen wert1 und wert2 in die int() – Funktion packt, werden die Werte von Python automatisch in eine Ganzzahl konvertiert. Nocheinmal zurück zum aneinander fügen von Strings Natürlich gibt es auch Anwendungsgebiete, die darauf abzielen, mehrere Einzelstrings zu einem String zusammen zu „bauen“. Einige weitere Datentypen str() -> Stringint() -> Ganzzahlfloat() -> Gleitkommazahllong() -> Lange Integercomplex -> Komplexe Zahlen

python3 How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 3 Version date: October 2012 by Peter Wentworth, Jeffrey Elkner, Allen B. Downey, and Chris Meyers (based on 2nd edition by Jeffrey Elkner, Allen B. Corresponding author: p.wentworth@ru.ac.za Source repository is at For offline use, download a zip file of the html or a pdf version (the pdf is updated less often) from Search PageCopyright NoticeForewordPrefacePreface-3 This Rhodes Local Edition (RLE) of the bookContributor ListChapter 1 The way of the programChapter 2 Variables, expressions, and statementsChapter 3 Hello, little turtles! String Formatting - Learn Python - Free Interactive Python Tutorial Python uses C-style string formatting to create new, formatted strings. The "%" operator is used to format a set of variables enclosed in a "tuple" (a fixed size list), together with a format string, which contains normal text together with "argument specifiers", special symbols like "%s" and "%d". Let's say you have a variable called "name" with your user name in it, and you would then like to print out a greeting to that user. # This prints out "Hello, John!" name = "John" print "Hello, %s!" % name Execute Code To use two or more argument specifiers, use a tuple (parentheses): # This prints out "John is 23 years old." name = "John" age = 23 print "%s is %d years old." % (name, age) Any object which is not a string can be formatted using the %s operator as well. # This prints out: A list: [1, 2, 3] mylist = [1,2,3] print "A list: %s" % mylist Here are some basic argument specifiers you should know:

2.4. Graphics — Hands-on Python Tutorial for Python 3.1 Graphics make programming more fun for many people. To fully introduce graphics would involve many ideas that would be a distraction now. This section introduces a simplified graphics module developed by John Zelle for use with his Python Programming book. My slight elaboration of his package is graphics.py in the example programs. Warning It is particularly important in Microsoft Windows with the graphics not to open Idle from the Start menu. To work on the most systems, this version of graphics.py cannot be used from the Idle shell. In Microsoft Windows, have Python version 3.4 or greater and be sure to start Idle in one of two ways: from the shortcut provided in the examples folder (in the same folder as graphics.py)or start by right clicking on an existing graphics program file in the same folder to get a context menu and choose Open With Idle:. 2.4.1. Note You will just be a user of the graphics.py code, so you do not need to understand the inner workings! Press return: 2.4.2. 2.4.3. or

Simple math of everything But for people who can read calculus, and sometimes just plain algebra, the drop-dead basic mathematics of a field may not take that long to learn. And it's likely to change your outlook on life more than the math-free popularizations or the highly technical math. Computer science Amdahl's law Relates the speedup of a sub-task to the resulting speedup of the whole. on Wikipedia, long with examples on MathWorld, short without examples Asymptotic notation Used to abstract away units and fixed overhead when analyzing resource usage. Deterministic finite state automata Traditional square one of theoretical computer science, with many practical applications. The pumping lemma for regular languages Illustrates many recurring themes. at Penn Engineering, explanation and examples handout (PDF) with concise statement and examples Cantor's diagonal argument An astonishingly elegant technique for proving certain kinds of theorems. on Wikipedia, definition and a step-through of the proof Halting Problem

Mit Python in MySQL Datenbanken arbeiten » elektronXelektronX Wer mit Python Daten erfassen, generieren oder speichern möchte, kann dies in Textdateien, Variablen oder eben einer Datenbank tun. Letzeres ist die eleganteste und sicherste Methode. Zudem kann hier eine fast unbegrenzte Menge an Datensätzen gespeichert und abgerufen werden. Ich möchte das am Beispiel der MySQL Datenbank erklären. Ein Vorteil ist hierbei, dass ich mit Python die Daten erfassen kann und im Browser per php die Datenbank darstellen kann. Als Beispiel nutze ich den altbewährten RFID Türöffner, den ich bereits hier vorgestellt habe. In der Datenbank sollen nun die Besitzer einer Zugangskarte hinterlegt werden, die zugehörige Kartennummer, die Anzahl der Zutritte sowie der jüngste Zugang der Person. Um das Thema etwas weiterzuspinnen, speichere ich zusätzlich noch einen Geldbetrag in jedem Datensatz. Meine Tabelle sieht nun wie folgt aus: Das System besteht aus 2 Teilen: – Der administrative Teil. Voraussetzungen für dieses Projekt: – LAMP Server mit pyphmyadmin – RFID Reader #! 21.

PEP 8 -- Style Guide for Python Code Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b. This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. In performance sensitive parts of the library, the ''.join() form should be used instead. This will ensure that concatenation occurs in linear time across various implementations.Comparisons to singletons like None should always be done with is or is not, never the equality operators.Also, beware of writing if x when you really mean if x is not None -- e.g. when testing whether a variable or argument that defaults to None was set to some other value. The other value might have a type (such as a container) that could be false in a boolean context!

Related: