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 is a number guess game. If the user guesses higher than the sum of the dice rolled they win!''' | |
from random import randint | |
from time import sleep | |
def get_user_guess(): | |
user_guess = int(raw_input("Guess a number: ")) | |
return user_guess | |
def roll_dice(number_of_sides): |
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 is a program that allows a user to view their calendar, add events,update events and delete events''' | |
from time import sleep, strftime | |
NAME = "Jasmine" | |
calendar = {} | |
def welcome(): | |
print "Welcome, " + NAME | |
print "THe calendar is opening..." |
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 rgb_hex(): | |
INVALID_MSG = "Invalid input. Please try again" | |
red = int(raw_input("Enter a value for red: ")) | |
if red < 0 or red > 255: | |
print INVALID_MSG | |
return | |
green = int(raw_input("Enter a value for green: ")) | |
if green < 0 or green > 255: | |
print INVALID_MSG | |
return |
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 is a program that calculates the area of triangles and circles''' | |
from math import pi | |
from time import sleep | |
from datetime import datetime | |
now = datetime.now() | |
print "The calculator is starting" | |
print "Current time: %s/%s/%s %s:%s" % (now.month, now.day, now.year, now.hour, now.minute) |
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 is a simple game of rock, paper, scissors!''' | |
from random import randint | |
from time import sleep | |
OPTIONS = ["R", "P", "S"] | |
LOSER = "You lost." | |
WINNER = "You won!" | |
def decide_winner(user_choice, computer_choice): |
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 is a program that tests the DNA sequences of 3 suspects and helps you determine which one is the likely culprit based on how many codon matches their sample contains''' | |
sample = ['GTA','GGG','CAC'] | |
def read_dna(dna_file): | |
dna_data = "" | |
with open(dna_file, "r") as f: | |
for line in f: | |
dna_data += line | |
return dna_data |
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 a list, say for example this one: | |
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
and write a program that prints out all the elements of the list that are less than 5. | |
Extras: | |
Instead of printing the elements one by one, make a new list that has all the |
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 number. Depending on whether the number is even or odd, | |
print out an appropriate message to the user. Hint: how does an even / odd | |
number react differently when divided by 2? | |
Extras: | |
If the number is a multiple of 4, print out a different message. | |
Ask the user for two numbers: one number to check (call it num) | |
and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, |
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
'''Character Input Create a program that asks the user to enter their name and | |
their age. Print out a message addressed to them that tells them the year that | |
they will turn 100 years old. | |
Extras: | |
Add on to the previous program by asking the user for another number and printing | |
out that many copies of the previous message. | |
Source:http://www.practicepython.org/ | |
''' |
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
'''Create a program that asks the user for a number and then prints out a list | |
of all the divisors of that number. (If you don’t know what a divisor is, it | |
is a number that divides evenly into another number. For example, 13 is a | |
divisor of 26 because 26 / 13 has no remainder.) | |
Source:http://www.practicepython.org/exercise/2014/02/26/04-divisors.html | |
''' | |
num = int(raw_input("Enter a number: ")) |
OlderNewer