Skip to content
Merged
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
12 changes: 9 additions & 3 deletions source/week-1/print/input.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# The input funciton allows you to prompt the user for a value
# The input function allows you to prompt the user to type something

# You need to declare a variable to hold the value entered by the user
Name = input('What is your name? ')
# IMPORTANT: When you declare a variable, it has to start with small letter
name = input('What is your name? ')

print('Great, your name is '+ Name)
print('Great, your name is ' + name)

# The user can type their name on the next line with the \n command / not on the same line as above
name = input("What is your name?\n")

print('Great, your name is ' + name)
9 changes: 6 additions & 3 deletions source/week-1/print/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
print('Hello world single quotes')

# Strings can also be enclosed in double quotes
print("Hello world double quotes")
print("Hello world - double quotes")

# using print to display integers
print(188)
# using print to display integer / whole numbers
print(188)

# using print to display float number / real number
print(99.9)
29 changes: 28 additions & 1 deletion source/week-1/variables/doing_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
first_num = 6
second_num = 2

# You can peform a variety of math operations on numeric values
# FIRST WAY OF DOING IT
"""# You can perform a variety of math operations on numeric values
print('addition')
print(first_num + second_num)
print('subtraction')
Expand All @@ -14,3 +15,29 @@
print(first_num / second_num)
print ('exponent')
print(first_num ** second_num)
"""

# SECOND WAY OF DOING IT

# importing operator module
import operator

# using add() to add two numbers
print("The addition of numbers is :", end="")
print(operator.add(first_num, second_num))

# using sub() to subtract two numbers
print("The difference of numbers is :", end="")
print(operator.sub(first_num, second_num))

# using mul() to multiply two numbers
print("The multiplication of numbers is :", end="")
print(operator.mul(first_num, second_num))

# using truediv() to divide two numbers
print("The division of numbers is :", end="")
print(operator.truediv(first_num, second_num))

# using pow() to find the power of two numbers
print("The power of numbers is :", end="")
print(operator.pow(first_num, second_num))
17 changes: 15 additions & 2 deletions source/week-1/variables/format_strings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# FIRST WAY
# the capitalize function will return the string with
# the first letter uppercase and the rest of the word lowercase

# Ask the user for their first and last name // it does not matter how the user types it:
# ALEX, alex, aLEX etc. --> it will be saved in the memory as Alex (Fist letter will be with uppercase)
first_name = input('What is your first name? ').capitalize()
last_name = input('What is your last name? ').capitalize()

print('Hello ' + first_name + ' ' + last_name)


# SECOND WAY
# Ask the user for their first and last name
first_name = input('What is your first name? ')
last_name = input('What is your last name? ')

# the capitalize function will return the string with
# the first letter uppercase and the rest of the word lowercase
print ('Hello ' + first_name.capitalize() + ' ' \
+ last_name.capitalize())
print('Hello ' + first_name.capitalize() + ' ' + last_name.capitalize())