Skip to content

Instantly share code, notes, and snippets.

View ofelix03's full-sized avatar

Felix Otoo ofelix03

View GitHub Profile
@ofelix03
ofelix03 / mysql.md
Created June 17, 2017 20:08
MySQL Tips

Installing MySQL

Run this command to install MySQL server, as well as the packages for the client and for the database common file:

sudo apt-get install mysql-server

NOTE: A dialog pops up for an optional root user password. (I advice you provide one).

Uninstalling MySQL Completely (Linux Systems)

Run the following commands:

@ofelix03
ofelix03 / modulos operator formatting string.py
Last active February 4, 2021 21:36
% formatting string
first_name = "Samuel"
surname = "Mensah"
# Positional placeholders using %s
print("Hello %s %s" %(first_name, surname)) # Results: Hello Samuel Mensah
# Named positional placeholders using %(name)s
print("Hello %(first_name)s %(surname)s") # Result: Hello Samuel Mensah
@ofelix03
ofelix03 / sum-of-numbers.py
Created February 21, 2021 17:46
A program to find the sum of N numbers
"""
Algorithm to find the sum of N numbers
Steps
1. Start
2. Declare and assigned variables, i=0, sum=0, N
3. Enter how many numbers you want to find their sum (N)
4. Enter number (num)
5. Add number(num) to sum ie sum = sum + num
6. Increase i by 1 ie i = i + 1
@ofelix03
ofelix03 / f-string-syntax.txt
Last active March 2, 2021 12:52
f-string syntax
f '<text> { <expression> <optional !s, !r, or !a> <optional : format specifier> } <text> ...'
@ofelix03
ofelix03 / f-string-example.py
Created March 2, 2021 12:54
f-string example
# Examples of f-string
first_name = "Felix"
surname = "Otoo"
print(f"Hello, I am {first_name} {surname}") # Result: Hello, I am Felix Otoo
@ofelix03
ofelix03 / comparing-interpolation-methods.py
Created March 2, 2021 12:56
Comparing interpolation methods (f-strings, Str.format and %-formatting string)
# Let starts with defining some variables
first_name = "Felix"
middle_name = "Albert"
last_name = "Otoo"
age = 28
profession = "Software Engineer"
# % formatting string
# Ex. 1 Using position placeholders
print("This is %s %s %s. He is %s years old. He is a %s" %(first_name, middle_name, last_name, age, profession))
@ofelix03
ofelix03 / str-format-method-string-contenation.py
Created March 2, 2021 12:57
String concatenation using the Str.format()
# Concatenation involving Str.format() strings
first_name = "Felix"
last_name = "Otoo
profession = "Software Engineer"
str_1 = "This is {first_name} {last_name}. ".format(first_name=first_name, last_name=last_name)
str_2 = "He is a {profession}. ".format(profession=profession)
str_3 = "He is from Ghana"
# Concatenating str_1, str_2 and str_3 using the plus(+) sign
@ofelix03
ofelix03 / mudulos-operation-string-contenation.py
Created March 2, 2021 12:59
String Concatenation using %-formatting
# Concatenation involving %-formatting strings
str_1 = "This is %s %s" %(first_name, last_name)
str_2 = "He is a %s. " % (profession)
str_3 = "He is from Ghana"
# Concatenating str_1, str_2 and str_3 using the plus(+) sign
str_4 = str_1 + str2 + str_3
print(str_4) # Result: This is Felix Otoo. He is a Software Engineer. He is from Ghana"
@ofelix03
ofelix03 / f-strings-concatenation.py
Created March 2, 2021 13:41
Concatenation involving f-strings
# Concatenation involving f-strings
#
# Unlike %-formatting and Str.format() examples above, we do not
# need the plus(+) sign
# or even evaluating and resolving final literal strings before
# joining them together
# We can achieve all of that with the f literal string.
str_1 = f"This is {first_name} {last_name}" f"He is a {profession}. " "He is from Ghana"
print(str_1) # Result: This is Felix Otoo. He is a Software Engineer. He is from Ghana"
@ofelix03
ofelix03 / concatenating-two-f-strings.py
Created March 2, 2021 13:42
Concatenating two f-strings
# This concatenates two f-strings
# 1st string f"This is {first_name} {last_name}
# 2nd string f"He is a {profession}"
print(f"This is {first_name} {last_name}. " f"He is a {profession}") # Result: This is Felix Otoo. He is a Software Engineer