Skip to content

Instantly share code, notes, and snippets.

View ItsCrem's full-sized avatar
🤠
*tips hat*

Crem ItsCrem

🤠
*tips hat*
View GitHub Profile
@ItsCrem
ItsCrem / CollatzSequence.py.py
Created November 16, 2017 14:11
CollatzSequence.py created by MaxCaminer - https://repl.it/@MaxCaminer/CollatzSequencepy
#Collatz Sequence
def collatz(number):
#If number is even then divide by 2 and then return number
if number % 2 == 0:
print(number // 2)
return number // 2
#If number is odd then times the number by 3 and add 1 then return number
elif number % 2 == 1:
result = 3 * number + 1
print(result)
@ItsCrem
ItsCrem / guessingGame.py
Created November 16, 2017 13:34
guessingGame created by MaxCaminer - https://repl.it/@MaxCaminer/guessingGame
# Guessing game from 1-10
import random
answer = random.randint(0, 3)
print("Please guess a number from 1-10!")
guess = int(input())
if (guess != answer):
if (guess < answer):
print("Guess higher!")
else: # If guess is higher than the answer
@ItsCrem
ItsCrem / stringFormattingPractice.py
Created November 16, 2017 13:27
stringFormattingPractice created by MaxCaminer - https://repl.it/@MaxCaminer/stringFormattingPractice
age = 24
#Old way
print("My age is " + str(age) + " years")
#New way
print("My age is {0} years".format(age))
print("There are {0} day in {1}, {2}, {3}, {4}, {5}, {6} and {7}".format(31, "January", "March", "May", "July", "August", "October", "December"))