Skip to content

Part 1 #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions myDoc/1. working_with_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Working With String
print("Vincent Adeniji") # Horizontal
print("Vincent\Adeniji") # Back Slash
print("Vincent\nAdeniji") # New Line / Vertical
print("Vincent\'Adeniji") #
print("Vincent\"Adeniji") #

# String Variable
name = "Vincent Adeniji"
print(name)

# Concatination
name = "Vincent Adeniji \n"
school = "Lambda School"
print(name + school)

# Function - a block of code that would perform a specific operation - modify, get info
school = 'Lambda Academy'
upperSchool = 'LAMBDA'
lowerSchool = 'lambda'

print(school.upper(), '22') # Make the string UpperCase
print(school.upper().isupper(), '23') # Make the string UpperCase, is the String UpperCase? output: True
print(school.lower(), '24')
print(school.lower().islower(), '25')
print(school.isupper(), '26')
print(school.islower(), '27')
print(upperSchool.isupper(), '28')
print(lowerSchool.islower(), '29')

print(len(school), 'length') # Length of the string
print(school[0]) # print the first letter
print(school.index('Lambda')) # Shows the index of the string. Note: only output the index of the first letter in the variable
print(school.replace('Academy', 'School')) # Replace
7 changes: 7 additions & 0 deletions myDoc/10. Return_Statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Return information from function

def cube(num):
return int(num) ** 3

result = cube(2)
print(result)
22 changes: 22 additions & 0 deletions myDoc/11. If_Statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Mahiya = "Crush"
crush = Mahiya
print(Mahiya)

if len(Mahiya) > len(crush) or 2: # If one condition is true
print("I love you Apu")
elif Mahiya == "crush" or crush:
print("I still love you apu")
elif crush == Mahiya:
print("I will always love you apu")
else:
print("Where's Apuuu")


if Mahiya == crush and "Crush": # If both condition is true
print("I love you a lot apu")


if Mahiya == "Crush" and not(crush): # This won't output because crush is Mahiya, but we are saying it isn't
print("I so much Love you Apu")
else:
print("Always love you apu")
10 changes: 10 additions & 0 deletions myDoc/12. If_Statement_and_comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Maximum number
def max_num(num1, num2, num3):
if num1 >= num2 and num1 >= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3

print(max_num(1, 2, 3))
19 changes: 19 additions & 0 deletions myDoc/13. Building_A_Better_Calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
num1 = float(input('Enter First Number: '))
operator = input('Enter operator: ')
num2 = float(input('Enter Second Number: '))


if operator == '+':
print(num1 + num2)
elif operator == '-':
print(num1 - num2)
elif operator == '*':
print(num1 * num2)
elif operator == '/':
print(num1 / mum2)
elif operator == '%':
print(num1 % num2)
elif operator == '^':
print(num1 ** num2)
else:
print("Invalid Operator")
13 changes: 13 additions & 0 deletions myDoc/14. Dictionaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Special Structure
# Allows us to store information in Key Value Pairs


monthConversion = {
"Jan": "January",
"Feb": "February",
"Mar": "March",
"Apr": "April",
}

print(monthConversion['Jan'])
print(monthConversion.get("Feb"))
6 changes: 6 additions & 0 deletions myDoc/15. While_Loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
i = 1
while i <= 10:
print(i)
i += 1

print("dONE")
17 changes: 17 additions & 0 deletions myDoc/16. Building_Guessing_Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
secret_word = "Apu"
guess = ""
guess_count = 0
guess_limit = 3
out_of_luck = False

while guess != secret_word and not(out_of_luck):
if guess_count < guess_limit:
guess = input('Enter Guess: ')
guess_count += 1
else:
out_of_luck = True

if out_of_luck:
print('Uh-oh!!! You Lose')
else:
print("You Win")
31 changes: 31 additions & 0 deletions myDoc/17. For_Loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#

for letter in "Lambda Academy":
print(letter) # Print all text in lamda academy


#

crushes = ["Apu", "Sis", "Love"]

for crush in crushes:
print(crush)

# index of 10
# Note index start from 0-9


for index in range(10):
print(index)

# range from 3 - 10

for index in range(3, 10):
print(index)

# Using range with Variable
crushes = ['Apu', 'Love', 'Beautiful'] # Variable

length = len(crushes) # Length Variable
for crush in range(length): # set a new Variable called crush and check the range of the length
print(crushes[crush]) # Output the range of the crushes names
11 changes: 11 additions & 0 deletions myDoc/18. Exponential_Function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def raise_to_num(base_pow, pow_num): # First create a function with two parameter
result = 1 # We set a variable to one for the iteration, 1 * anything will always give us anything
for i in range(pow_num): # Now we create a variable and set it in range of the second paremeter
result = result * base_pow # and we use the result for the actual base. for example, let the base = 100, range = 3
# 100 * result = 100, that is 1. the loop still need to go up 2 more times
# now result is 100, the second time will be 100 * 100 = 10,000 one more to go
# result now is 10,000. 10,000 * 100 = 1,000,000.
# Note the base remain the same.
return result # Now we return the result which is now 1,000,000.
# After a return statement we can't do anything except printing
print(raise_to_num(100,3)) # Now we print the call function
Empty file.
57 changes: 57 additions & 0 deletions myDoc/2. working_with_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Print the actual number
print(2) # Whole Number
print(2.2) # Decimal Number
print(-2)
print(-2.2)

# Arithmetics
print(2 + 2) # Plus
print(2 + 2.2)

print(2 * 2 ) # Multiplication
print(2 * -2)

print(2 * 2 + 2)
print(2 * (2 + 2)) # Parenthesis

print(10 % 3) # Modulos gives the remainder, 10/3 remains 1

# Store Number inside a Variable

num = 7
print(num)

# Convert Number to string
# Note you can't use number and string together, so you need to convert the number to string
print(str(num)) #Note, the actual number is now string
print(str(num) + " is the first letter of my name")

# Absolute Value
num = -4, -4.34
print(abs(num[0]), abs(num[1]))

# raise to Power
num = 5
print(pow(num, 2))

# Maximum Number
print(max(num, 2, 4))

# Mininum Number
print(min(num, 2, 4))

# Round Number
num = 4.1
print(round(num))

# Floor Number. Note: this will remove any .int
# Note: you need to import math to use code below
from math import *

print(floor(num))

# Ceil Number. Round the number as long as there's int above 0
print(ceil(num))

# Square Root of a number
print(sqrt(num))
4 changes: 4 additions & 0 deletions myDoc/3. getting_input_from_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Input. Allow you to type what you want
name = input("Enter your name: ")
lname = input("Enter your last name: ")
print("I'm " + name + lname + " !")
13 changes: 13 additions & 0 deletions myDoc/4. building_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Addition
num1 = input("Enter the first number: ")
num2 = input("Enter the second number: ")
result = float(num1) + float(num2) #note: int will look for a whole number not float.

print(result)

# Subtraction
num1 = input("Enter the first number: ")
num2 = input("Enter the second number: ")
result = float(num1) - float(num2) #note: int will look for a whole number not float.

print(result)
8 changes: 8 additions & 0 deletions myDoc/5. Mad_Lib_Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
color = input("Enter a color: ")
pnoun = input("Enter a noun: ")
celebrity = input("Enter a celebrity: ")


print(f"Roses Are {color}")
print(f"{pnoun} Are blue")
print(f"I Love You, {celebrity}")
12 changes: 12 additions & 0 deletions myDoc/6. List.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mutable
friends = ["Big", "Bang", "Apu", 2, False]

print(friends)
print(friends[1])
print(friends[-5])
print(friends[2:]) # from index 2 to rest of the friends
print(friends[2:3]) # print all the element from 2 and up to, but not including 3

# Modify
friends[2] = "Crush"
print(friends)
64 changes: 64 additions & 0 deletions myDoc/7. List_Function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
numbers = [1, 2, 3, 4, 5, 6]
crush = ["Apu", "Friend"]

print(numbers)
print(crush)

# Extend add two list together
# Note: you can add the same list
crush.extend(crush)
print(crush)

numbers.extend(crush)
print(numbers)

# Append add a specific info
# Note: add item at the end of the list
crush = ["Apu", "Friend"]

crush.append("Love")
print(crush)

# Insert to anywhere on the index
# Note: insert add new item to any index on the list and shift the previous index to the front
# for example ex = [Foo, Bar]. ex.insert(1, 'bang'). ex = [Foor, Bang, Bar]
crush.insert(1, 'Sis')
print(crush)

# Remove the item from the list
# Note: you can remove using the variable array or the of the item
crush.remove(crush[1])
crush.remove("Friend")
print(crush)

# Clear remove everything from the list
crush.clear()
print(crush, 'cleared')

# POP remove the last item off the list
# Note: if you print the function you will get what got poped
crush = ["Apu", "Sis", "Love"]
crush.pop()
print(crush.pop()) # Print and remove last item
print(crush)

# Count

crush = ["Apu", "is", "Beautiful"]
crush.extend(crush)
print(crush.count("Apu")) # Output 2\
print(crush)

# Sort
# Note: sort in ascending order
crush.sort()
print(crush)

# Reverse the order in the list
crush.reverse()
print(crush)

# Copy the list to another variable
crush = ['Apu', 'Lady M']
sis = crush.copy()
print(sis)
5 changes: 5 additions & 0 deletions myDoc/8. Tuples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Similar to a list
# Immutable - can't be change or modify
coordinates = (7, 9)
print(coordinates) # Output: 7, 9
print(coordinates[0]) # Output: 7
15 changes: 15 additions & 0 deletions myDoc/9. Function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Hello
def say_hi(name, age):
print("Hello " + name + " I am " + str(age))

say_hi("Vincent", 23)
say_hi("Ryan", 33)


# Greetings
def Greetings():
Greeting = "Hello "
name = input("Enter your name here: ")
print(Greeting + name)

Greetings()
7 changes: 7 additions & 0 deletions myDoc/js_creating_new_method_with_jsfunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const lovers = {
name: "Apu",
age: parseInt("Sweet 16"),

}

console.log(lovers)
Loading