# What is a float in python

 Brief overview of programming with Python

### Data types

 Integer i = 1 Integer Float f = 0.1 Floating point number String s = "Hello" String list l = [1, 2, 3] Changeable list with order Tuple t = (1, 2, 3) Unchangeable list with sequence Dictionary d = {1: "one", 2: "two", 3: "three"} Associative array

### Conversion of data types

int (2.33) returns 2

float (3) returns 3.0

str (53) returns the number 53 as a string

### arithmetic

+ (plus), -(minus), * (times), / (divided by), ** (high), % (Modulo, remainder of a division)

16/3 returns 5 (integer division), 16.0 / 3 returns 5.333333333333333 (floating point number division)

### Comparisons

==(equal), != (not equal),> (larger), <(smaller),> = (larger or equal), <= (smaller or equal)

### logic

true (true), false (not correct), other (simultaneously), or (or), not (Not)

### Element relationship

in (in the crowd), e.g. 3 in [1, 2, 3] (true), 4 not in [1, 2, 3] (true)

### Strings

Strings can be used with + linked or with * be repeated, e.g.

"ABC"+“Def“ returns “abcdef“, 5*"A" delivers "AAAAA"

### Sequences

Sequences are called tuples (1, 2, 3) and lists [1, 2, 3]. In contrast to dictionaries, sequences are ordered, i.e. each element has a unique position, starting with position 0 (Zero) for the first element of the list, -1 can be set for the last element, e.g. (3, 4, 5)  returns 3, (3, 4, 5) [- 1] returns 5

### List Generators

range (10) equivalent to [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], range (1.4) corresponds to [1,2,3]

### Function definition

def square (x): return x ** 2square (3) returns 9

### Commands for numbers and strings

round (a [, n]) - rounds a floating point number. Optionally, the number of decimal places can be specified, e.g.
round (5.59555, 2) returns 5.6

str () - convert to string, float () - convert to floating point number.

You can use not only numbers, but generally all objects str () convert to a string, e.g.
print(str(167) [- 1]) yields 7

len() - Determine the length of the string, e.g.

test_string = "Today"

len(test_string) returns 5

### Control structures

if-elif-else                      Example:

x = 8 if x> 5: print ("x is greater than 5") elif x <5: print ("x is less than 5") else:      print ("x is 5" Output: x is greater than 5while               Example: i = 0 while i <4: print ("i is", i) i = i + 1 Output: i is 0 i is 1 i is 2 i is 3 for                Example:for i in range (10.21): print(i * i, end = '' 100 121 144 169 196 225 256 289 324 361 400 break,Example:continue and else for i in "Hello World!":if i == "":break print (i, end = '') Output: Hello

### Modules

from ... import ... e.g. from math import * Importance: Everything (*) is imported from the math module.

### Input and output

a = input (“Text“) #Entering the variable aprint “Text“, a # Output of text and value of the variable a

Example:

i = 99

print ('% 3d% 1.6f'% (i, 1.0 / i)

Output:

99   0.010101

### Program input

The program input is best done in a new Windows window (Ctrl + N) after calling IDLE (Python GUI).

Back