View no_teen_sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
View lucky_sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
View String_splosion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
View Front_back_change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
View Guess_game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created on Mon Jul 3 16:07:34 2017 | |
@author: nickikku | |
""" | |
import random | |
d = int(random.randint(1,10)) | |
#print(d) | |
e = 1 |
View Rock_paper_scissors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
View List_overlap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |