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
license: cc-by-4.0 |
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
license: gpl-3.0 |
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
license: gpl-3.0 |
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
__author__ = 'David Gotz, [email protected]' | |
print('Hello, World!') |
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
# Get the current mileage and the mileage at the last oil change. | |
current_mileage = int(input("Enter the current mileage: ")) | |
last_change_mileage = int(input("Enter mileage for last oil change: ")) | |
# Check for valid input. | |
if current_mileage < last_change_mileage: | |
# Display an error if invalid input is found. | |
print('The current mileage is less than the last change mileage. Please try again.') | |
else: | |
# Calculate difference in mileage |
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
##### | |
# Start with player 1, who chooses the number to guess | |
##### | |
# Ask player 1 for a value between 0 and 100 | |
##### | |
# Now it is time for player 2 to guess... | |
##### |
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
##### | |
# Start with player 1, who chooses the number to guess | |
##### | |
# Ask player 1 for a value between 0 and 100 | |
target_number = int(input('Player 1: Enter a number between 0 and 100: ')) | |
##### | |
# Now it is time for player 2 to guess... | |
##### |
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
# Print "size" lines where size is the size of the pattern. | |
size = 15 | |
#for line in range(size): # 0, 1, 2, 3, 4 | |
# # Print spaces (0, 1, 2, 3, 4) | |
# for space in range(line): | |
# print(' ', end='') | |
# | |
# # Print stars (5, 4, 3, 2, 1) | |
# for star in range(size-line): |
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
# Prints the requested number of symbols without a newline. | |
def print_symbol(symbol, count): | |
for i in range(count): | |
print(symbol, end='') | |
# Draws a single line of spaces and symbols using the given size/line number. | |
def print_line(size, symbol, line_num): | |
# Print spaces | |
print_symbol(' ', line_num) |
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 | |
# Returns a random value from 1-6 with uniform distribution. | |
def roll(): | |
return random.randint(1, 6) | |
# Simulates a pair of dice | |
def roll_dice(): |
OlderNewer