Strings, lists, tuples, integers, float, dictionaries, and sets are all types of python objects with different properties and uses. When using an object in a program or in your terminal, your session assigns an Id to access the computer's memory. The Id will be unique each session and on each …
read more2010 Guess The Number Game
During my first month of learning python, I wrote a game to guess a number between 1 and 20 with six attempts. This simple game is good practice for a beginner. A better written and more advanced version can be found at http://housewifehacker.com/intermediate-guess-number-python-game.html. This example is …
read moreDecimal to Change Number Precision
The built in math functions in Python use binary approximations, giving some funky results when dealing with numbers containing decimals:
>>> .1 + .2 0.30000000000000004 >>> round(100.00 / 3.000, 4) 33.333300000000001
One way to appropriately find the sum of decimals is to use strings
read more>>> str(.1 + .2) '0.3 …
Map Function in Python
Today I discovered the map function in Python. Map causes some simple for loops to be verbose and unnecessary. Let's look at how to change a list of integers to a list of strings. First we'll use a for loop:
read more>>> list = [1, 2, 3, 4, 5] >>> index = 0 >>> for x …
Indexes, Strings, and Lists
A Python string's properties can be best understood by using sentences and words, although numbers can also be stored as strings. Be careful not to name a string as 'str' or 'string', because these are built in functions in Python. Let's play with some basic functions you can do to …
read moreMath With Python
If this is your first time using Python in Windows, you will have to download it from python.org. Every operating system includes a terminal, which we will be using to practice and test. Google "How to open terminal" and your operating system name to find specific information about opening …
read more
« Page 2 / 2