Skip to content

Instantly share code, notes, and snippets.

#adds only if values are no teens, exept for 15 & 16.
def no_teen_sum(a, b, c):
if ((a > 10 and a < 15) or (a > 16 and a < 20)) and ((b > 10 and b < 15) or (b > 16 and b < 20)) and ((c > 10 and c < 15) or (c > 16 and c < 20)):
return 0
if (a > 10 and a < 15) or (a > 16 and a < 20):
if (b > 10 and b < 15) or (b > 16 and b < 20):
return c
#lucky number is 13 in this case. It means that when input == 13, it will stop the sum of a + b + c.
def lucky_sum(a, b, c):
if a == 13: #if a == 13 it returns 0
return 0
elif b == 13: #if b == 13 it returns only a
return a
elif c == 13: #if c == 13 it returns the sum of a + b
return a + b
else: #if none of them are 13, the sum of a + b + c is calculated
#this function returns lenght of the string number of times of input string. If the string contains 3 characters, it will return
#character 1 + 1, 2 + 1, 2, 3
def string_splosion(str):
a = ''
for i in range(len(str)):
a += str[:(i+1)]
return a
def front_back(str):
if len(str) <= 1: #if the string only has one character, it returns just that one.
return str
a = str[1:-1] #takes the string without the first and the last character.
return str[-1] + a + str[0] #adds the last, the middle and the first sections together.
@Nickikku
Nickikku / Rock_paper_scissors
Last active July 3, 2017 19:08
Rock_paper_scissors
Created on Mon Jul 3 15:15:26 2017
@author: nickikku
"""
print("Let\'s play the game: \'rock, paper, scissors\'")
g = 10
a = input("player one, please enter your name: ")
b = input("player two, please enter your name: ")
while g > 0:
@Nickikku
Nickikku / Guess_game
Last active July 3, 2017 14:31
Guess_game
Created on Mon Jul 3 16:07:34 2017
@author: nickikku
"""
import random
d = int(random.randint(1,10))
#print(d)
e = 1
@Nickikku
Nickikku / List_overlap
Last active July 3, 2017 12:23
Simple_exercises_python
Created on Mon Jul 3 12:14:05 2017
@author: nickikku
"""
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c = []
for i in a:
if i in b: