Skip to content

Instantly share code, notes, and snippets.

@mightywombat
mightywombat / string_lists.py
Created April 20, 2018 17:48
practicepython.org Ex 06
# practicepython.org Ex 06
word_og = raw_input("Palindrome checker. Enter your palindrome: ")
word = word_og.replace(" ", "")
start = 0
while (len(word) / 2) > start:
end = -(start + 1)
if word[start] == word[end]:
@mightywombat
mightywombat / list_overlap.py
Last active April 19, 2018 21:06
practicepython.org Ex 05
# practicepython.org Ex 05
import random as ra
def randrng():
numlist = []
rnglen = ra.randrange(10, 20)
while rnglen > 0:
numlist.append(ra.randrange(1, 100))
rnglen -= 1
@mightywombat
mightywombat / lt_five.py
Created April 18, 2018 22:25
practicepython.org Ex 03
# practicepython.org Ex 03
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
z = []
for integer in a:
if (integer < 5):
z.append(integer)
print (z)
@mightywombat
mightywombat / odd_even.py
Last active April 18, 2018 22:25
practicepython.org Ex 02
# practicepython.org Ex 02
num = int(raw_input ( "Enter a number you would like divided: " ))
check = int(raw_input ( "Enter a number you want to divide by: "))
rem = str( num % check )
divby2 = num % 2
if divby2 == 0:
print ( str(num) + " is EVEN." )
else:
print ( str(num) + " is ODD." )
@mightywombat
mightywombat / ppex01.py
Created April 18, 2018 21:39
practicepython.org Ex 01
# practicepython.org Ex 01
name = raw_input( "Please enter your name: " )
age = int(raw_input ( "Please enter your age: " ))
age = str( 100 - age )
print ( "Hi, " + name + "! You will turn 100 years old in " + age + " years!" )
@mightywombat
mightywombat / fileboop.py
Last active April 24, 2018 12:22
File Backup & Verify (Mac/*nix)
import os
import shutil
import hashlib
# Define variables
directory = raw_input( "Drag and drop the file or folder you want to back up." ) # Accepts input from user for source file path.
directory = directory.rstrip(" ") + "/" # Formats variable.
backup_path = raw_input( "Drag and drop the location to which you want to back up." ) # Accepts input from user for destination file path.
backup_path = backup_path.rstrip(" ") + "/" # Formats variable.
errnum = 0