Created
December 30, 2020 10:38
-
-
Save yigitkerem/3ff9b6b7f79d60d85c85dba3b4eed572 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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