Lists

  • A list is a sequence of several variables, grouped together under a single name
list = ["apples", "cherries", "peaches"]
print(list)
['apples', 'cherries', 'peaches']

2d Lists

  • A 2D array is an array of arrays that can be represented in matrix form, like rows and columns.
arr=[[1,2,3],
[4,5,6],
[7,8,9]]

print(arr)
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

Dictionaries

  • a set of words or other text strings made for use in applications such as spelling checkers.
thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}
print(thisdict)
{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}

Class

  • a class is a template definition of the method s and variable s in a particular kind of object
class MyClass:
  x = 5
p1 = MyClass()
print(p1.x)
5

Algorithms

  • An algorithm is a step-by-step procedure that defines a set of instructions that must be carried out in a specific order to produce the desired result.
def isPalindrome(s):
    return s == s[::-1]
 
 
# Driver code
s = "malayalam"
ans = isPalindrome(s)
 
if ans:
    print("Yes")
else:
    print("No")
Yes

Sequence

  • the order that commands are executed by a computer

Selection

  • Selection is a programming construct where a section of code is run only if a condition is met

Iteration

  • sequence of instructions or code being repeated until a specific end result is achieved
cars = ["Aston", "Audi", "McLaren"]
i = 0
while (i < len(cars)):
    print (cars[i])
    i += 1
Aston
Audi
McLaren

Truth Tables

  • A truth table is a breakdown of all the possible truth values returned by a logical expression

Operators

  • an operator is a character that represents a specific mathematical or logical action or process

Parameters

  • special kind of variable in computer programming language that is used to pass information between functions or procedures.
def my_function(parameter):
  print(parameter + " Refsnes")

my_function("Emil")
my_function("Tobias")
my_function("Linus")
Emil Refsnes
Tobias Refsnes
Linus Refsnes