Skip to content

Instantly share code, notes, and snippets.

View shamikalashawn's full-sized avatar
💭
Polishing my latest app!

Shamika La Shawn shamikalashawn

💭
Polishing my latest app!
View GitHub Profile
@shamikalashawn
shamikalashawn / Return Percentage
Created February 6, 2017 23:06
This function returns the percentage of an hour that the minutes provided represent.
def return_percentage(minutes):
percentage = (minutes/60)*100
return int(percentage)
@shamikalashawn
shamikalashawn / Nested While Loop Box
Created February 6, 2017 23:04
A "*" box is created using nested while loops.
def nested_while_loop_box():
row = 0
col = 0
box = ''
while row < 4:
while col < 4:
box = box + '****'
row += 1
box = box + '\n'
col += 1
@shamikalashawn
shamikalashawn / Nested Pyramid
Created February 6, 2017 23:03
A pyramid created from the "*" character is returned using nested for loops.
def nested_pyramid():
pyramid = ''
for num in range(1):
for char in range(1,6):
pyramid = pyramid + '*' * char + '\n'
return pyramid
@shamikalashawn
shamikalashawn / Nested For Loop Box
Last active February 6, 2017 23:05
A box of the character "*" is created using nested for loops.
def nested_box():
box = ''
for col in range(4):
if col == 0:
box = box
else:
box = box + '\n'
for row in range(4):
box = box + '*'
box = box + '\n'
@shamikalashawn
shamikalashawn / MadLib
Created February 6, 2017 22:59
The most simple of MadLibs.
noun = input('Please enter a noun')
verb = input('Please enter a verb')
adjective = input('Please enter an adjective')
adverb = input('Please enter an adverb')
print ('The ' + adjective + noun + verb + adverb)
@shamikalashawn
shamikalashawn / Is Reverse
Created February 6, 2017 22:56
Two words are compared. If one word is the reverse of the other, the function returns "True". Otherwise the function returns "False".
def is_reverse(word1, word2):
if len(word1) != len(word2):
return False
i = 0
j = len(word2)-1
while j > -1:
print (i, j) #print here
if word1[i] != word2[j]:
@shamikalashawn
shamikalashawn / Inverted Pyramid
Created February 6, 2017 22:54
This function returns an upside down pyramid with the "*" character and a widest width of 5.
def inverted_pyramid():
pyramid = ''
pylength = [1,2,3,4,5]
for num in range(1):
for char in reversed(pylength):
pyramid = pyramid + '*' * char + '\n'
return pyramid
@shamikalashawn
shamikalashawn / Highest Number Cubed
Created February 6, 2017 22:52
Given a numerical limit, the function returns the highest number cubed that is still less than the limit.
def highest_number_cubed(limit):
answer = 0
for num in range(limit):
print (num**3)
if num**3 > limit:
answer = num - 1
return answer
@shamikalashawn
shamikalashawn / Hello
Created February 6, 2017 22:50
A little more than "hello world", this program asks for your name and age and then greets you with a little information about yourself.
#This program says hello and asks for my name
print('Hello world')
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
@shamikalashawn
shamikalashawn / Ducklings
Created February 6, 2017 22:48
The letters from "J" to "Q" are turned into onomatopoeias with the suffix "ack".
prefixes = 'JKLMNOPQ'
suffix = 'ack'
for letter in prefixes:
if letter == 'O' or letter == 'Q':
print (letter + 'u' + suffix)
else:
print (letter + suffix)