Skip to content

Instantly share code, notes, and snippets.

@yigitkeremoktay
Created December 30, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yigitkeremoktay/3ff9b6b7f79d60d85c85dba3b4eed572 to your computer and use it in GitHub Desktop.
Save yigitkeremoktay/3ff9b6b7f79d60d85c85dba3b4eed572 to your computer and use it in GitHub Desktop.
# The text that start with hashes are called comments. They are not visible to your computer, so you can put anything
# there.
# Functions allow us to do something (they trigger an action)
print("Text")
# Variables store data
aVariable = "Hi" # Strings are wrapped between quotes
aNumberVariable = 11 # Variables can also store numbers
aTextNumber = "9" # Note that this different.
# Boolean Variables
aCondition = True
anotherCondition = False
# Structures
if(aCondition):
print(aVariable)
if(anotherCondition):
print("Nope")
# Logical Statements
# == Equal
# < Smaller
# > Bigger
# <= Smaller or Equal
# >= Bigger or Equal
# Using IF Statements for conditions
if(aNumberVariable > 10):
print("Condition is met")
# Mathematical Operations
x = 6
y = 10
# Multiplication
z = 6*10
# Addition
q = 6+y
# Subtraction
v = y-10
# Division
n = 10/x
# Our own functions
def getSquared(number):
result = number*number
return result
# Getting returned values
squared = getSquared(10)
print(getSquared(10))
# While
i = 0
while(i < 10):
print("Hey")
i = i+1
# Combining All We Have Learned
def getPower(number,exponent):
i = 0
result = 1
while(i < exponent):
result = result*number
i = i+1
return result
print(getPower(27,4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment