Skip to content

Instantly share code, notes, and snippets.

View tahmidefaz's full-sized avatar
🐑
-ing

Tahmid Efaz tahmidefaz

🐑
-ing
View GitHub Profile
#!/usr/bin/env python
import re
import json
import sys
report = {
}
reporters = ['ingress', 'puptoo', 'rhsm-conduit', 'yupana']
# This function does not take any parameters and
# doesn't return any value. A non-fruitful function.
def simple_function():
a = 10
b = 20
a + b
def function_with_parameters(w, v, u):
'''
A non-fruitful function that takes three parameters
num = 10
# simple way to print 10 to 2
while num > 1:
print(num)
num -= 1
# This would have been an infinite loop if not for the break
while True:
if num == 10:
fruits = ['apple','orange','banana','peach']
for fruit in fruits:
print(fruit)
# This will print from 0 to 9
for i in range(10):
print(i)
# This will print 5 to 7 range(start, end)
# list creation
simple_list = [1, 5, 8]
print('List indexing is a thing:', simple_list[0])
print('Negative number to show the end item', simple_list[-1])
simple_list.append(12) # [1, 5, 8, 12]
simple_list.append(21) # [1, 5, 8, 12, 21]
print('get a portion of a list [start:end]', simple_list[1:3]) # [5, 8]
# Nested if-statements
if True:
if 2 < 3:
print('This is how you write nested if')
# If-else statements
if 's' == 's':
print('If-else statement, guys!')
else:
print("This won't show up, sadly")
if 23 == 23:
print('This uses indentions')
if(23 === 23){
console.log('This is using curly braces');
}
# Declaring some variables
a = 3
b = 7
a > b # False
a < b # True
a >= b # False -- greater than or equal to
a <= b # True -- less than or equal to
a == b # False -- a equals b
1 + 4 # 5
12 - 3 # 9
7 * 8 # 56
10/3 # 3.3333....
16 % 5 # 1 - modulus operator, the remainder of the division
16 // 5 # 3 - floor division operator
2**3 # 8 - exponentiation operator