Show Menu
Cheatography

Programming Cheat Sheet (DRAFT) by

Unlock the power of coding with our Ultimate Programming Cheat Sheet! Whether you're a seasoned developer or just diving into the world of programming, this comprehensive reference guide has got you covered. Packed with essential syntax, tips, and tricks for popular programming languages such as Python, JavaScript, Java, C++, and more, this cheat sheet is your go-to resource for quick problem-solving and efficient coding.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Iteration

For loop
While loop
for i in range (...,...):
i = 1
-print (i * 100)
while i <= 5:
-> number of reptat­ionis known.
-print ( i * 100 )
 
-i = i + 1
 
-> number of repeti­tions is unknown.
In summary, while loops are more flexible in terms of the condition they evaluate, making them suitable for situations where the number of iterations is not known beforehand or might change during runtime. For loops are ideal when you need to iterate over a sequence of known length or a predefined collec­tion.

Sub Programs

declar­ation of the procedure
declar­ation of the function
def proced­ure­_na­me(­param01 , param02):
def functi­on_­nam­e(p­ara­1_,­para2):
   action(s)
   action(s)
   proced­ure­_na­me(­par­am01, param02)
   return variab­le_name / expression 
 
In summary, the key difference lies in whether the block of code returns a value or not. Functions return values, while procedures do not. However, in languages like Python, the distin­ction is less strict, as functions can return None and procedures can still be defined using functions that return None. The choice of using functions or procedures depends on the specific requir­ements of the task and the progra­mming paradigm being followed.

Recurs­ivity

def factor­ial(n):
   if n == 0: 
      return 1
   else:
       return n * factor­ial(n - 1)
This is the condition that stops the recursive calls.
Recursion can be a powerful tool for solving problems that can be broken down into smaller, similar subpro­blems. However, it's essential to ensure that the base case is reachable and that the recursive calls converge towards the base case to avoid infinite recursion. Additi­onally, recursive solutions may not always be the most efficient, as they can consume more memory due to the recursive calls creating a new stack frame for each function call.

String

String
Length
concat­ena­tions
comparing
iterating
character membership
other predefined
Assign­ment:
s1 = "­1LB­C1"
s = "­1LB­C1"
s1 = "­abc­d"
for c in s:
code
code
variab­le_name = "­val­ue"
L=len(s1)
s1 = "­ASD­P2"
s2 = "­abc­d"
code
code
code
s1 = 1LBC1
print(L)
s2 = s + s1
s3 = "­abc­d1"
code
code
code
Access to characters
-> displays 5
print (s2)
if s1 == s2:
code
code
code
s1 = "­1LB­C1"
s1 = "­1LB­C1"
*->­display "­1LBC1 ASP2"
  print ("s1 and s2 are simila­r")
code
code
code
s1 = "­1LB­C2"
s2 = s1 [1 : 4]
 
else:
code
code
code
print (s1)
print (s2)
 
  print ("s1 and s2 are differ­ent­")
-> displays "­1LB­C2"
->d­isplays "­LBC­"
 
if s1 == s3:
     
  print ("s1 and s3 are simila­r")
     
else:
     
  print ("s1 and s3 are differ­ent­")