sync
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,63 +1,63 @@
|
||||
s1 = [2, 1, 4, 3]
|
||||
s2 = ["c","a","b"]
|
||||
print("------------Discussion Part 1----------")
|
||||
|
||||
# s1 + s2
|
||||
print("-----s1 + s2-----")
|
||||
print(s1 + s2)
|
||||
|
||||
print()
|
||||
|
||||
#b) 3 * s1 + 2 * s2
|
||||
print("--------3 * s1 + 2 * s2-----")
|
||||
print(3 * s1 + 2 *s2)
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print(3 * s1 + 2 * s2)
|
||||
print()
|
||||
|
||||
#c) s1[1]
|
||||
print("--------s1[1]-----")
|
||||
print(s1[1])
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#d) s1[1:3]
|
||||
print("--------s1[1:3]-----")
|
||||
print(s1[1:3])
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#e) s1 + s2[-1]
|
||||
print("--------s1[1:3]------")
|
||||
print("--------s1 + [s2[-1]])------")
|
||||
print(s1 + [s2[-1]])
|
||||
print()
|
||||
|
||||
print("------------Discussion Part 2----------")
|
||||
#a)s1.remove(2)
|
||||
print("s1.remove(2)")
|
||||
print(s1.remove(2))
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#b)s1.sort()
|
||||
print("s1.sort()")
|
||||
print(s1.sort())
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#c)s1.append([s2.index("b")]
|
||||
print("s1.append([s2.index("'b'")])")
|
||||
print(s1.append([s2.index("b")]))
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#d)s2.pop(s1.pop(0))
|
||||
print("s2.pop(s1.pop(0))")
|
||||
print(s2.pop(s1.pop(0)))
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
print()
|
||||
|
||||
#e)s2.insert(s1[1], "d"
|
||||
#e)s2.insert(s1[1], "d")
|
||||
print("s2.insert(s1[1], "'d'")")
|
||||
print(s2.insert(s1[1], "d"))
|
||||
print(f"This is the value of s1: {s1}")
|
||||
print(f"This is the value of s2: {s2}")
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import random
|
||||
|
||||
def makedeck():
|
||||
ranks = list(range(2, 11)) + ['J', 'Q', 'K', 'A']
|
||||
suits = ['h', 'd', 'c', 's']
|
||||
deck = [(rank, suit) for suit in suits for rank in ranks]
|
||||
return deck
|
||||
|
||||
def shuffledeck(deck):
|
||||
random.shuffle(deck)
|
||||
return deck
|
||||
|
||||
def dealcard(deck):
|
||||
return deck.pop()
|
||||
|
||||
def straight_flush(hand):
|
||||
return flush(hand) and straight(hand)
|
||||
|
||||
def four_of_a_kind(hand):
|
||||
ranks = [card[0] for card in hand]
|
||||
return any(ranks.count(rank) == 4 for rank in ranks)
|
||||
|
||||
def fullhouse(hand):
|
||||
ranks = [card[0] for card in hand]
|
||||
rank_counts = {rank: ranks.count(rank) for rank in set(ranks)}
|
||||
return 3 in rank_counts.values() and 2 in rank_counts.values()
|
||||
|
||||
def flush(hand):
|
||||
suits = [card[1] for card in hand]
|
||||
return len(set(suits)) == 1
|
||||
|
||||
def straight(hand):
|
||||
rank_order = {str(k): k for k in range(2, 11)}
|
||||
rank_order.update({'J': 11, 'Q': 12, 'K': 13, 'A': 14})
|
||||
|
||||
ranks = sorted(rank_order[str(card[0])] for card in hand)
|
||||
return all(ranks[i + 1] - ranks[i] == 1 for i in range(len(ranks) - 1))
|
||||
|
||||
def three_of_a_kind(hand):
|
||||
ranks = [card[0] for card in hand]
|
||||
return any(ranks.count(rank) == 3 for rank in ranks)
|
||||
|
||||
def two_pair(hand):
|
||||
ranks = [card[0] for card in hand]
|
||||
unique_pairs = [rank for rank in set(ranks) if ranks.count(rank) == 2]
|
||||
return len(unique_pairs) == 2
|
||||
|
||||
def pair(hand):
|
||||
ranks = [card[0] for card in hand]
|
||||
return any(ranks.count(rank) == 2 for rank in ranks)
|
||||
|
||||
def testhands():
|
||||
hand1 = [(2, 'h'), (3, 'h'), (4, 'h'), (5, 'h'), (6, 'h')] # Straight flush
|
||||
hand2 = [(10, 'c'), (10, 'd'), (10, 'h'), (10, 's'), (2, 'h')] # Four of a kind
|
||||
hand3 = [(10, 'c'), (10, 'd'), (10, 'h'), (2, 's'), (2, 'h')] # Full house
|
||||
hand4 = [(2, 'h'), (4, 'h'), (6, 'h'), (8, 'h'), (10, 'h')] # Flush
|
||||
hand5 = [(2, 'h'), (3, 'd'), (4, 'c'), (5, 's'), (6, 'h')] # Straight
|
||||
hand6 = [(10, 'c'), (10, 'd'), (10, 'h'), (2, 's'), (3, 'h')] # Three of a kind
|
||||
hand7 = [(10, 'c'), (10, 'd'), (2, 's'), (2, 'h'), (3, 'h')] # Two pair
|
||||
hand8 = [(10, 'c'), (10, 'd'), (2, 's'), (3, 'h'), (4, 'h')] # Pair
|
||||
|
||||
print("-------------------This is a test case -----------------------")
|
||||
print(f"Hand 1 Straight Flush: {straight_flush(hand1)}") # True
|
||||
print(f"Hand 2 Four of a Kind: {four_of_a_kind(hand2)}") # True
|
||||
print(f"Hand 3 Full House: {fullhouse(hand3)}") # True
|
||||
print(f"Hand 4 Flush: {flush(hand4)}") # True
|
||||
print(f"Hand 5 Straight: {straight(hand5)}") # True
|
||||
print(f"Hand 6 Three of a Kind: {three_of_a_kind(hand6)}") # True
|
||||
print(f"Hand 7 Two Pair: {two_pair(hand7)}") # True
|
||||
print(f"Hand 8 Pair: {pair(hand8)}") # True
|
||||
|
||||
def discussion1():
|
||||
cards_per_hand = 5
|
||||
|
||||
#First assignment printout
|
||||
fulldeck = makedeck()
|
||||
print("Full Deck: ")
|
||||
for card in fulldeck:
|
||||
print(f"Card: {card}")
|
||||
|
||||
#Ask how many players
|
||||
while True:
|
||||
try:
|
||||
num_hands = int(input('How many players are there? '))
|
||||
if num_hands > 0:
|
||||
print(f"The number of players is {num_hands} players")
|
||||
break
|
||||
else:
|
||||
print('Please enter a positive number of players')
|
||||
except ValueError:
|
||||
print('Please enter a number of players instead.')
|
||||
|
||||
#Create a list of hand values
|
||||
hands = [[] for _ in range(num_hands)]
|
||||
|
||||
#Deal the cards
|
||||
for round_nm in range(1):
|
||||
|
||||
shuffled_deck = shuffledeck(fulldeck)
|
||||
print(f"Round {round_nm + 1}:")
|
||||
for hand_index in range(num_hands): # Iterate through each hand
|
||||
print(f"Hand {hand_index + 1}:")
|
||||
for card_num in range(cards_per_hand): # Deal cards to the current hand
|
||||
card = shuffled_deck.pop()
|
||||
hands[hand_index].append(card)
|
||||
|
||||
print(hands[hand_index])
|
||||
|
||||
def main():
|
||||
discussion1()
|
||||
testhands()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,53 @@
|
||||
# sumnN(n) returns the sum of the first n natural numbers.
|
||||
# sumNCubes(n) returns the sum of the cubes of the first n natural numbers.
|
||||
|
||||
# Then use these functions in a program that prompts a user for an n and prints out the sum of the first n natural numbers and the sub of the cubes of the first n natural numbers.
|
||||
|
||||
# What the heck is a natural number?
|
||||
# number that is positive and whole
|
||||
|
||||
# Prompt function
|
||||
def prompt():
|
||||
promptresponse = int(input("Please enter a number for n:"))
|
||||
return promptresponse
|
||||
|
||||
def sumN(n):
|
||||
sum = 0 #initialize sum for use
|
||||
print("Let's show the work for the sum of the natural numbers:\n")
|
||||
for i in range(1,n+1): # start building the natural numbers leading up to n.
|
||||
sum += i
|
||||
if sum != n+1:
|
||||
string_concatenate = f"{i} + " # concatenate the string to show the user the sum
|
||||
else:
|
||||
string_concatenate = f"{i}"
|
||||
print(string_concatenate, end="") # print the string
|
||||
print(f" = {sum}") # print the sum
|
||||
return sum # return the sum to the function
|
||||
|
||||
def sumNCubes(n):
|
||||
sum = 0 #initialize sum for use
|
||||
for i in range(1,n+1): # start building the natural numbers leading up to n.
|
||||
sum += i**3 # add the cube of the number to the sum
|
||||
if sum!=n+1:
|
||||
string_concatenate = f"{i}^3 + "
|
||||
else:
|
||||
string_concatenate = f"{i}^3"
|
||||
print(string_concatenate, end="") # print the string
|
||||
return sum # return the sum to the function
|
||||
|
||||
# Main Function
|
||||
def main():
|
||||
# Prompt the user for n.
|
||||
n=prompt()
|
||||
print(f"The sum for sumN of the 'natural numbers is': {sumN(n)}")
|
||||
|
||||
print(f"The sum for sumN of the 'natural numbers is': {sumNCubes(n)}")
|
||||
|
||||
# Ask the user to see if they want to continue
|
||||
continueprompt = input("Would you like to continue? (y/n)")
|
||||
if continueprompt == "y":
|
||||
main()
|
||||
else:
|
||||
print("Goodbye!")
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,79 @@
|
||||
# Implement a class to represent a playing card. Your class should have the following methods:
|
||||
# __init__(self, rank, suit) rank is an integer from 1 to 13, indicating the suit (diamonds, clubs, hearts or spades).
|
||||
# Create the corresponding card.
|
||||
|
||||
# getRank(self) returns the rank of the card.
|
||||
# getSuit(self) Returns the sute of the card
|
||||
|
||||
#value(self) Returns the blackjack value of a card. Ace counts as 1, ace cards count as 10.
|
||||
|
||||
#__str__(self) Returns a string that names the card. For example, "Ace of Spades".
|
||||
|
||||
#Note: A method named __str__ is special in Python. If asked to convert an object into a string, python uses this method, if it's present. For example,
|
||||
|
||||
# c = Card(1,"s")
|
||||
# print callable
|
||||
|
||||
# will print "Ace of Spades"
|
||||
#Test your card class with a program that prints out n randomly generated cards and the associated blackjack value where n is a number supplied by the user.
|
||||
|
||||
import random
|
||||
|
||||
class PlayingCard:
|
||||
def __init__(self, rank, suit): #initialize the rank and suit of the card object
|
||||
self.rank = rank #assign the rank to the card object
|
||||
self.suit = suit #assign the suit to the card
|
||||
|
||||
def getRank(self):
|
||||
return self.rank #return the rank of the card
|
||||
|
||||
def getSuit(self):
|
||||
return self.suit #return the suit of the card
|
||||
|
||||
def value(self):
|
||||
if self.rank == 1: #if the rank of the card is 1, return 1
|
||||
return 1
|
||||
elif self.rank > 10: #if the rank of the card is greater than 10, return 10
|
||||
return 10
|
||||
else:
|
||||
return self.rank #return the rank of the card
|
||||
|
||||
def __str__(self):
|
||||
if self.rank == 1:
|
||||
rank = "Ace"
|
||||
elif self.rank == 11:
|
||||
rank = "Jack"
|
||||
elif self.rank == 12:
|
||||
rank = "Queen"
|
||||
elif self.rank == 13:
|
||||
rank = "King"
|
||||
else:
|
||||
rank = self.rank
|
||||
if self.suit == "d":
|
||||
suit = "Diamonds"
|
||||
elif self.suit == "c":
|
||||
suit = "Clubs"
|
||||
elif self.suit == "h":
|
||||
suit = "Hearts"
|
||||
elif self.suit == "s":
|
||||
suit = "Spades"
|
||||
|
||||
return f"{rank} of {suit}"
|
||||
|
||||
def main():
|
||||
while True:
|
||||
try:
|
||||
n = int(input("Enter the number of cards: ")) # ask the user to choose how many cards to "draw"
|
||||
for i in range(n): # loop through the number of card the user has selected to draw
|
||||
rank = random.randint(1, 13) #randomly generate the rank of the card in n round between 1 and 13
|
||||
suit = random.choice("dchs") #randomly generate the suite of the card in n round between d, c, h, s
|
||||
card = PlayingCard(rank, suit) # assign the previously generated values to the card object and create the card by calling the class and passing the rank and suit as arguments and assign it to the card variable and create the card object and assign it to the card variable and create the card object and assign it to the card variable
|
||||
print(f"Card: {card}, Value of Card: {card.value()}") # print out the card tuple and the value of the card
|
||||
except ValueError:
|
||||
print("Please enter a valid number")
|
||||
except:
|
||||
print("An error occured")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,39 @@
|
||||
# Write an automated censor program that reads in the text from a file and creates a new file where all of the four letter words have been replaced by "****". You can ignore punctuation and you may assume that no words in the file are split across multiple lines.
|
||||
|
||||
import os
|
||||
|
||||
def Censor_Words(input_file, output_file):
|
||||
print(f"Censoring words in file: , {input_file} and writing them to {output_file}\n")
|
||||
#check if output file exists and if not then create it
|
||||
if not os.path.exists(output_file):
|
||||
open(output_file, 'w').close()
|
||||
else:
|
||||
print(f"{output_file} already exists. Overwriting it.\n")
|
||||
try: # try to open the file and write to the output file
|
||||
with open(input_file, 'r') as f: # open the file, using r to read read it
|
||||
text = f.read() # read the file
|
||||
words = text.split() # split up the words
|
||||
for i in range(len(words)): # loop through the words. Len(words) gives the number of words in the list
|
||||
if len(words[i]) == 4: # if the word is 4 characters, then replace it with ****
|
||||
print(f"Word {words[i]} censored.\n") #output the word that was censored for troubleshooting.
|
||||
words[i] = "****"
|
||||
|
||||
with open(output_file, 'w') as f: # open the output file, using w to write to it
|
||||
f.write(" ".join(words))
|
||||
print("Censoring document complete. Results found in output.txt\n")
|
||||
except FileNotFoundError:
|
||||
print("File wasn't found.")
|
||||
except:
|
||||
print("An error occurred.")
|
||||
|
||||
def __main__():
|
||||
script_directory = os.path.dirname(os.path.abspath(__file__)) # get the directory of the script
|
||||
input_file = os.path.join(script_directory, "input.txt") #had to use os.path.join to get the correct path. Wasn't working with just the file name
|
||||
output_file = os.path.join(script_directory, "output.txt") # had to use the os.path.join to get the correct path dynamically. Wasn't working with just the file name
|
||||
print(f"Input file: {input_file}\n, Output file: {output_file}\n") # troubleshooting the file name issues. Show the input and output in console.
|
||||
Censor_Words(input_file, output_file) # call the function to start censoring
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
__main__() # call the main function and get things started.
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
# Week 8 - Lab: Python Program
|
||||
# Assignment Value: 10 points
|
||||
# Description:
|
||||
|
||||
# Create a Python program that demonstrates exception handling.
|
||||
# Your program should include at least three custom-defined exceptions and handle them appropriately.
|
||||
# Implement try-except blocks to handle exceptions and provide meaningful error messages.
|
||||
# Test your program with various scenarios to ensure proper exception handling.
|
||||
|
||||
# Instructions:
|
||||
|
||||
# Create a Python script named exception_handling.py.
|
||||
# Define three custom exceptions: CustomError1, CustomError2, and CustomError3.
|
||||
# Implement a function divide_numbers() that takes two numbers as input and returns the result of dividing the first number by the second number.
|
||||
# Handle the ZeroDivisionError exception. If the second number is zero, raise CustomError1.
|
||||
# Implement a function open_file() that takes a filename as input and tries to open the file.
|
||||
# Handle the FileNotFoundError exception. If the file does not exist, raise CustomError2.
|
||||
# Implement a function process_data() that takes a list as input and tries to access an element at a specific index.
|
||||
# Handle the IndexError exception. If the index is out of range, raise CustomError3.
|
||||
# In the main part of your script, demonstrate the usage of all the implemented functions by invoking them and handling exceptions appropriately.
|
||||
# Take a screenshot of Thonny showing both the code and output at the end of the exercise.
|
||||
# Upload the screenshot.
|
||||
|
||||
# Directions for submitting your written assignment as an attachment:
|
||||
|
||||
# When you have completed the assignment, save the file on your computer with your name as part of the file name, for example, a_student_assignment1.docx [using your first initial and last name]
|
||||
# Click on the title of the assignment above.
|
||||
# Click on "Upload Files".
|
||||
# Click on the "Browse Local Files" button to attach your file to this assignment.
|
||||
# Once you have attached your file, click on the "Submit" button to send your file to your instructor.
|
||||
|
||||
# Note: This assignment is due 11:59 PM ET, Sunday of Week 8.
|
||||
|
||||
import os
|
||||
|
||||
def divide_numbers(num1, num2):
|
||||
try:
|
||||
print(f"Dividing numbers {num1} / {num2}")
|
||||
if num2 == 0:
|
||||
raise CustomError1
|
||||
return num1 / num2
|
||||
except CustomError1:
|
||||
print("CustomError1: Cannot divide by zero.")
|
||||
|
||||
def open_file(input_file):
|
||||
try:
|
||||
print(f"Trying to open the {input_file}")
|
||||
with open(input_file, 'r') as f:
|
||||
print(f"{input_file} has been opened successfully.")
|
||||
pass
|
||||
except FileNotFoundError:
|
||||
raise CustomError2
|
||||
|
||||
def process_data(data, index):
|
||||
try:
|
||||
print(f"Trying to return the data for each index.")
|
||||
return data[index]
|
||||
|
||||
except IndexError:
|
||||
raise CustomError3
|
||||
|
||||
class CustomError1(Exception):
|
||||
pass
|
||||
|
||||
class CustomError2(Exception):
|
||||
pass
|
||||
|
||||
class CustomError3(Exception):
|
||||
pass
|
||||
|
||||
def __main__():
|
||||
script_directory = os.path.dirname(os.path.abspath(__file__)) # get the directory of the script
|
||||
input_file = os.path.join(script_directory, "input.txt") #had to use os.path.join to get the correct path. Wasn't working with just the file name
|
||||
fail_input_file = os.path.join(script_directory, "doesnotexist.txt")
|
||||
try:
|
||||
print("\n\n----------Division Function-------------")
|
||||
print("----------------------------------------")
|
||||
print(f"Failure case: {divide_numbers(10, 0)}")
|
||||
print(f"Success case: {divide_numbers(100, 10)}")
|
||||
|
||||
except CustomError1:
|
||||
print("CustomError1 handled.")
|
||||
|
||||
print("----------End Division Function---------\n\n")
|
||||
|
||||
|
||||
try:
|
||||
print("---------Open File Function-------------")
|
||||
print("----------------------------------------")
|
||||
print(f"Success Case: Trying to open {input_file}")
|
||||
open_file(input_file)
|
||||
|
||||
print(f"Fail Case: Trying to open {fail_input_file}")
|
||||
open_file(fail_input_file)
|
||||
|
||||
except CustomError2:
|
||||
print("CustomError2 handled.")
|
||||
|
||||
print("---------End Open File Function---------\n\n")
|
||||
|
||||
|
||||
try:
|
||||
print("-------Process List Input Function------")
|
||||
print("----------------------------------------")
|
||||
print(f"Failure case: {process_data([1, 2, 3], 3)}")
|
||||
print(process_data([1, 2, 3], 2))
|
||||
|
||||
except CustomError3:
|
||||
print("CustomError3 handled.")
|
||||
|
||||
try:
|
||||
print("-------Process List Input Function------")
|
||||
print("----------------------------------------")
|
||||
print(f"Success case: {process_data([1, 2, 3], 2)}")
|
||||
|
||||
except CustomError3:
|
||||
print("CustomError3 handled.")
|
||||
|
||||
print("----End Process List Input Function-----\n\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
__main__()
|
||||
@@ -0,0 +1,9 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce auctor cursus arcu non interdum. Phasellus lacus diam, cursus a quam vel, molestie tincidunt nisl. Suspendisse congue finibus lectus, in imperdiet eros imperdiet sit amet. Curabitur hendrerit a magna ultrices aliquet. Pellentesque tortor felis, varius quis aliquam ultrices, dictum nec lorem. Duis diam mauris, semper et enim vel, lobortis porta tellus. Sed nec venenatis urna, in pharetra justo. Vestibulum ac fringilla mi, eget vulputate nisi. Fusce eget vehicula velit. Nullam vel mauris lectus. Cras eleifend condimentum pulvinar. Nulla congue, elit id iaculis aliquet, quam mauris volutpat magna, ut semper nisi lectus vitae neque. In ornare vehicula metus, ac placerat erat pellentesque at.
|
||||
|
||||
Nam vel massa ac leo aliquam ultricies. Maecenas tempor, diam ac cursus venenatis, metus lacus mollis dui, sit amet suscipit felis erat in urna. Suspendisse ante ex, luctus in dui quis, lobortis sodales lectus. Nullam rutrum accumsan libero, in semper nibh consectetur sit amet. Donec accumsan non turpis eu finibus. Mauris gravida metus at ipsum fringilla molestie. In ante tellus, semper porta lorem non, tincidunt tempus quam. Praesent finibus pellentesque enim, sit amet gravida nulla accumsan a.
|
||||
|
||||
Vivamus molestie odio justo, at suscipit ex malesuada ut. Phasellus sit amet tortor porta elit bibendum accumsan a sit amet erat. Nulla varius sodales urna, id tempus mi molestie in. Ut turpis est, varius nec tellus nec, vehicula tempus nunc. Nullam erat justo, pellentesque et ullamcorper ut, rhoncus quis nibh. Sed ut ultrices ipsum. Nulla tellus est, scelerisque a sodales ac, molestie in est. Nullam nec placerat est. Duis vel metus ipsum. Pellentesque placerat sit amet sem et imperdiet. Suspendisse vulputate elit sit amet ex lobortis, vitae egestas tortor auctor. Sed accumsan sapien ut sem ultrices efficitur.
|
||||
|
||||
Praesent suscipit risus quis ipsum pretium cursus. Morbi velit nibh, facilisis tincidunt nisl a, aliquet vulputate est. Vestibulum id commodo felis. Curabitur sit amet interdum ante. Maecenas metus sem, imperdiet vel ligula vehicula, mollis egestas velit. Fusce luctus nibh mollis, suscipit mi et, hendrerit ipsum. Etiam ut blandit felis, ac eleifend turpis. Sed nibh ipsum, convallis sit amet elementum eget, laoreet fringilla ex. Curabitur semper nec metus eget venenatis. Praesent efficitur vitae nulla quis placerat. Nullam porta nulla in dignissim tempus. Aliquam erat volutpat.
|
||||
|
||||
In a massa dignissim, luctus dolor at, commodo ligula. Proin odio nisl, auctor ut tempus non, ultrices non purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam eleifend diam nec sem pretium, molestie facilisis urna pellentesque. Vestibulum feugiat metus quis lorem aliquam, ac varius lorem tincidunt. In consectetur tempus massa facilisis placerat. Cras tincidunt justo nulla, ut tristique urna dignissim nec. Maecenas orci nunc, faucibus sed sem vel, vestibulum cursus urna. In hac habitasse platea dictumst. Ut facilisis scelerisque nunc ut feugiat. Donec viverra orci in nisi finibus congue. Etiam consectetur vel neque eu posuere. Aliquam erat volutpat.
|
||||
@@ -0,0 +1 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce auctor cursus **** non interdum. Phasellus lacus diam, cursus a **** **** molestie tincidunt nisl. Suspendisse congue finibus lectus, in imperdiet **** imperdiet sit amet. Curabitur hendrerit a magna ultrices aliquet. Pellentesque tortor felis, varius **** aliquam ultrices, dictum nec lorem. **** **** mauris, semper et **** **** lobortis porta tellus. Sed nec venenatis urna, in pharetra justo. Vestibulum ac fringilla mi, **** vulputate nisi. Fusce **** vehicula velit. Nullam vel mauris lectus. **** eleifend condimentum pulvinar. Nulla congue, **** id iaculis aliquet, **** mauris volutpat magna, ut semper **** lectus vitae neque. In ornare vehicula metus, ac placerat **** pellentesque at. Nam vel massa ac leo aliquam ultricies. Maecenas tempor, **** ac cursus venenatis, metus lacus mollis **** sit **** suscipit felis **** in urna. Suspendisse **** ex, luctus in dui quis, lobortis sodales lectus. Nullam rutrum accumsan libero, in semper **** consectetur sit amet. Donec accumsan non turpis eu finibus. Mauris gravida metus at ipsum fringilla molestie. In **** tellus, semper porta lorem **** tincidunt tempus quam. Praesent finibus pellentesque enim, sit **** gravida nulla accumsan a. Vivamus molestie **** justo, at suscipit ex malesuada ut. Phasellus sit **** tortor porta **** bibendum accumsan a sit **** erat. Nulla varius sodales urna, id tempus mi molestie in. Ut turpis **** varius nec tellus **** vehicula tempus nunc. Nullam **** justo, pellentesque et ullamcorper ut, rhoncus **** nibh. Sed ut ultrices ipsum. Nulla tellus **** scelerisque a sodales ac, molestie in **** Nullam nec placerat **** **** vel metus ipsum. Pellentesque placerat sit **** sem et imperdiet. Suspendisse vulputate **** sit **** ex lobortis, vitae egestas tortor auctor. Sed accumsan sapien ut sem ultrices efficitur. Praesent suscipit risus **** ipsum pretium cursus. Morbi velit nibh, facilisis tincidunt **** a, aliquet vulputate **** Vestibulum id commodo felis. Curabitur sit **** interdum ante. Maecenas metus **** imperdiet vel ligula vehicula, mollis egestas velit. Fusce luctus **** mollis, suscipit mi et, hendrerit ipsum. Etiam ut blandit felis, ac eleifend turpis. Sed **** ipsum, convallis sit **** elementum eget, laoreet fringilla ex. Curabitur semper nec metus **** venenatis. Praesent efficitur vitae nulla **** placerat. Nullam porta nulla in dignissim tempus. Aliquam **** volutpat. In a massa dignissim, luctus dolor at, commodo ligula. Proin **** nisl, auctor ut tempus **** ultrices non purus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam eleifend **** nec sem pretium, molestie facilisis **** pellentesque. Vestibulum feugiat metus **** lorem aliquam, ac varius lorem tincidunt. In consectetur tempus massa facilisis placerat. **** tincidunt justo nulla, ut tristique **** dignissim **** Maecenas **** nunc, faucibus sed sem **** vestibulum cursus urna. In hac habitasse platea dictumst. Ut facilisis scelerisque **** ut feugiat. Donec viverra **** in **** finibus congue. Etiam consectetur vel neque eu posuere. Aliquam **** volutpat.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
def windchill_table(formula):
|
||||
|
||||
#print header columns
|
||||
print("\t", end="")
|
||||
for temp in range(-20, 61, 10):
|
||||
print(f"{temp}\t", end="")
|
||||
print("\n-----------------------------------------------------------------------------") # Print the dang header and Add a newline after the temperature header
|
||||
|
||||
for v in range(0, 51, 5):
|
||||
print(f"{v}\t", end="") # Print wind speed
|
||||
for temp in range(-20, 61, 10): # loop through the temp range to add a value to each cell
|
||||
# Calculate windchill using the provided formula
|
||||
windchill = 35.74 + 0.6215 * temp - 35.75 * (v ** 0.16) + 0.4275 * temp * (v ** 0.16)
|
||||
if v == 0:
|
||||
print ("N/A\t", end="") # Print N/A for wind speed 0
|
||||
else:
|
||||
print(f"{windchill:.2f}\t", end="") # Print windchill with one decimal place
|
||||
print() # Add a newline after each row of windchill values
|
||||
|
||||
def main():
|
||||
print("This program computes the windchill index.")
|
||||
print("print a table to show the windchill index for a range of temperatures and wind speeds.")
|
||||
windchill_table(0)
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,11 @@
|
||||
my_string = "Hello"
|
||||
|
||||
|
||||
|
||||
for i in range(3):
|
||||
|
||||
print(my_string, end=" ") # Prints "Hello " three times on the same line
|
||||
|
||||
|
||||
|
||||
print("World!")
|
||||
Reference in New Issue
Block a user