Programming Theory

Python Operators 

Data Types 

The above a the main data types you will have used.  

You could add a boolean type this can represent True or False only. 

Casting a data type - i.e. changing it.  

age = int(input("Enter your age"))  -  this code will make the input from the user be an integer. 

Built in functions in Python 

There are lots of built in functions in python 

You can identify them because they have a () after them. 

print() -  will print whatever is in the brackets to the screen

str() will convert a number inside the brackets to a string 

len() will return the length of a string or a list etc. 

range()  defines a range of numbers or characters - e.g.  range(10)  returns 0 to 9 

Methods 

There are lots of methods that are associated with a type of data - these work like functions above but are tied to one type of data use - often strings.  

String methods 

myname = "dave"    

myuppername = myname.upper()  

the above code uses the method    .upper()  to convert lowercase letters to uppercase. 

some other string methods: 


Programming Language - for example Python, C# - Used to "code" / make programs. 

Input - A way of getting the program user to put data in - like answering a question for example. 

Output - for example the print("Hello World") statement - output to the screen. 

Code comment - a line in the code that does not run but tells the programmer (or someone else) what the code is doing.  Python uses # to comment out a line. 

String - a sequence of characters could be letters, numbers, symbols, spaces. 

Function Call - a piece of code that "calls" another piece of code - so print() is a function call - it calls the print function that is built into the python language. 

Variable - an identifier (name) that can take a value and be changed. - i.e. name = "Dave"  

Operator - carries out an "operation" like + for add or * for times.  - see left of page. 

Data Type - the kind of data a variable holds - for example integer or string. 

Selection - where the code branches - where a question is asked - if x == 10:   for example - the code only executes if the condition is met. 

indentation - where the code is stepped in from the left to show it is part of a construct - like  if or while. 

iteration - looping - where the code is done over and over again until a number of times is reached or a condition met. 

for loop - done a set number of times. 

while loop - done until a condition is met 

case - upper or lower case letters

function - a piece of code that can be called and returns a value 

method - a built in piece of code that can be used with a type of data - like strings.