Skip to content

Instantly share code, notes, and snippets.

View sojohnnysaid's full-sized avatar
💾

John James sojohnnysaid

💾
View GitHub Profile
@sojohnnysaid
sojohnnysaid / python_command_line_args_1.py
Last active January 19, 2021 22:57
python command line arguments
import sys
def main():
if len(sys.argv) == 2:
print(f"the program name is {sys.argv[0]}")
print(f"hello, {sys.argv[1]}")
for eachArg in sys.argv:
for eachChar in eachArg:
print(eachChar)
@sojohnnysaid
sojohnnysaid / python_string_end_argument.py
Created November 2, 2019 14:53
Python using the end argument in a string
# Print any number of question marks
def main():
names = ['john', 'cassie', 'nori']
for name in names:
print(f"{name}",end=" is awesome!")
print()
if __name__ == "__main__":
@sojohnnysaid
sojohnnysaid / python_mario_again.py
Last active January 19, 2021 22:56
Python Mario again!
# create a mario pyramid in python!
from cs50 import get_int
def main():
# Prompt user for a positive number
while True:
n = get_int("enter a positive number: ")
if n > 0:
@sojohnnysaid
sojohnnysaid / Python_integer_overflow_1.py
Created November 2, 2019 14:28
Python integer overflow
from time import sleep
# Iteratively triple i
i = 1
while True:
print(i)
i *= 3
sleep(1)
@sojohnnysaid
sojohnnysaid / python_input_validation_1.py
Created November 2, 2019 14:14
Python validating input getting started
# get a positive integer from the user
from cs50 import get_int
def main():
x = getPositiveInteger("Please enter a positive integer: ")
print(f"Thanks for entering {x}!")
'''
for validating user input the logic is
@sojohnnysaid
sojohnnysaid / python_functions_getting_started.py
Last active January 19, 2021 22:56
Python functions getting started
from cs50 import get_int
def main():
x = get_int("Give me a number please: ")
print(
f"{x} to the power of 5 equals "
f"{powerOfFive(x)}. Wow that is "
"probably a big number!")
def powerOfFive(x):
@sojohnnysaid
sojohnnysaid / python_logic_operators1.py
Created November 2, 2019 01:38
Python logic operators
from cs50 import get_string
c = get_string("enter Y or N if this is fun: ")
if c == "Y" or c == "y":
print("glad you are having fun")
if c == "N" or c == "n":
print("it gets better...")
@sojohnnysaid
sojohnnysaid / python_logic_getting_started.py
Created November 2, 2019 01:31
python logic getting started
from cs50 import get_int
# get input from the user
x = get_int("x: ")
y = 42
if x < y:
print("x is less than y")
elif x > y:
@sojohnnysaid
sojohnnysaid / python_operators.py
Last active January 19, 2021 22:56
python operators
from cs50 import get_int
# prompt the user for a number
x = get_int("Enter a number: ")
# perform arithmetic
#addition
print(f"{x} plus {x} is equal to {x + x}")
#subtraction
print(f"{x} minus {x} is equal to {x - x}")
#multiplication
@sojohnnysaid
sojohnnysaid / scrapping.js
Created October 27, 2019 00:30
scrapping
const puppeteer = require('puppeteer');
const fs = require('fs');
const HTMLParser = require('node-html-parser');
const urls = ['https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-JetBlue',
'https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-or5-JetBlue#REVIEWS',
'https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-or10-JetBlue#REVIEWS',
'https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-or15-JetBlue#REVIEWS',
'https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-or20-JetBlue#REVIEWS',
'https://www.tripadvisor.com/Airline_Review-d8729099-Reviews-or25-JetBlue#REVIEWS',