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
import random | |
from IPython.display import clear_output | |
def onep_game(c1, p1): | |
bot_choice = random.choice(["stone", "paper", "scissors"]) | |
clear_output() | |
print("Bot choices %s" % bot_choice) | |
if c1 == "stone": | |
if bot_choice == "stone": | |
result = "Tie 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
#Ask the user for a string and print out whether this string is a palindrome or not. | |
string = str(raw_input("Give me a string: ")) | |
def reverse_string(to_be_reversed): | |
return to_be_reversed[::-1] | |
reversed = reverse_string(string) | |
if reversed == string: |
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
# Take two random lists and write a program that returns a list that contains only the elements that are | |
# common between the lists (without duplicates). Make sure your program works on two lists of different sizes. | |
import random | |
a = [] | |
b = [] | |
c = [] | |
for i in range(5): |
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
import datetime | |
now = datetime.datetime.now() | |
name = str(raw_input("name?: ")) | |
age = int(raw_input("age?: ")) | |
repeat = int(raw_input("How many times?: ")) | |
century = ((100 - age) + now.year) | |
message = "How are you %s? You are going to have a hundrer years on the year %d \n" % (name,century) | |
print message * repeat |