This file contains hidden or 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 time #used for the timing of the code | |
| def fibRecurse(n): #this will calculate the nth Fibonacci number recursively | |
| if n<=1: #This will get the 1st Fibonacci number of 0 | |
| return n | |
| else: | |
| return fibRecurse(n-1) + fibRecurse(n-2) | |
This file contains hidden or 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 | |
| import os | |
| #creating list and making them all uppercase and splitting the words | |
| wordlist = "Thor Fury Hulk Stark Thanos Ragnarok Odin Daredevil Wolverine Punisher ".upper().split() | |
| random.shuffle(wordlist) #getting a random list. need more words to truly scramble | |
| #images for the status of game | |
| HANGMANPICS = [''' |
This file contains hidden or 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 unittest #python module that handles unit testing | |
| def main(): | |
| """ The main method for this program | |
| This program will ask the user for an encryption key, if they want to | |
| encrypt or decrypt, and what message they want to encrypt or decrypt. | |
| Then the program will output output the message after it has been | |
| translated | |
| """ |
This file contains hidden or 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 #adding this library | |
| play_game = True #helps to kick out of the game later when we change to false | |
| another_game=str(input("Do you want to play a game, type yes or no ")) #gives player a choice to play again or not | |
| if another_game == "no": | |
| play_game = False | |
| else: | |
| play_game = True | |
| while play_game: #setting the stage with variables and initial input from user |
This file contains hidden or 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 | |
| play_game = True | |
| playerScore=0 | |
| dealerScore=0 | |
| cards = [ | |
| '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', | |
| '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', | |
| '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', | |
| '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', |
This file contains hidden or 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 #adding this library | |
| play_game = True #helps to kick out of the game later when we change to false | |
| while play_game: #setting the stage with variables and initial input from user | |
| n = random.randint(1,100) | |
| total = 0 | |
| guess = (input("Enter a integer from 1 to 100 or quit to leave game: ")) | |
| while guess !=n: #this loop will run as long as the input is not equal to random number | |
| if guess == 'quit': #this gives the user a chance to leave game midway through |
This file contains hidden or 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
| cost = int(input("Please enter the price of the item in cents ")) | |
| payment = int(input("Please enter the amount you paid in cents ")) | |
| change = payment - cost | |
| print("Your total change is", change, "and you will receive the following denominations") | |
| # // is floating division | |
| #Divides and returns the integer value of the quotient. | |
| #It dumps the digits after the decimal. |
This file contains hidden or 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
| from random import choice | |
| grades = '54 - Alice,35 - Bob,27 - Carol,27 - Chuck,05 - Craig,30 - Dan,27 - Erin,77 - Eve,14 - Fay,20 - Frank,48 - Grace,61 - Heidi,03 - Judy,28 - Mallory,05 - Olivia,44 - Oscar,34 - Peggy,30 - Sybil,82 - Trent,75 - Trudy,92 - Victor,37 - Walter' | |
| student_list = grades.split(',') | |
| final = sorted(student_list, reverse = False) | |
| print(final) |
This file contains hidden or 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
| ryears = int(input("How many (human) years old is your dog? ")) | |
| dyears = str(real_years * 7) | |
| print ("Your dog is " + dyears + " years old in dog years.") |
This file contains hidden or 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
| # Python program to check if number is prime or not | |
| number = int(input("Provide a number to test if it is prime: ")) | |
| if number > 1: | |
| for i in range(2, number//2): | |
| # If number is divisible by any number between 2 and n / 2, it is not prime | |
| if (number % i) == 0: |
NewerOlder