Shift Ciphers = Caesar Ciphers
A shift cipher, also known as a Caesar cipher, is a simple encryption technique used to disguise messages by shifting each letter in the alphabet by a fixed number of positions. It is one of the most basic and widely known encryption methods, often referenced in discussions about cryptography and encryption.
In a shift cipher, each letter of the alphabet is substituted with another letter that is a fixed number of positions away. For example, if we have a shift of 3, then "A" would be replaced by "D", "B" by "E", and so on. The shift wraps around the alphabet, so "Z" would be replaced by "C" in this case.
Shift ciphers fall into the category of substitution ciphers, where each letter in the plaintext is replaced with another letter or symbol. They are relatively easy to implement and understand, making them a common starting point for learning about encryption techniques.
There are two main types of ciphers: block ciphers and stream ciphers. A block cipher encrypts data in fixed-size blocks, while a stream cipher encrypts data continuously as it is transmitted.
While shift ciphers are straightforward and easy to use, they are also relatively easy to break through brute force methods or frequency analysis, especially with modern computing power. Despite their simplicity, they serve as a foundational concept in cryptography and provide insight into more complex encryption algorithms.
The average waiting time to see a medical doctor in the emergency room is 18 min. The standard deviation is 4 min. If a person goes to the emergency room, find the probability that he or she will wait between 6 and 14 min to see a doctor.
Sorted array
Find middle point by [n]/2, then round down
Comparing a search with middle point
Time Complexity = Order of Growth
Space Complexity
The system should allow the customer to input the items (1, 2, 3, 4), and
input customer name
add as many items as customer wants,
calculate the time for the order to be ready,
calculate the total, and
print the receipt.
List of items (Item, Price, Preparation Time)
1. Sandwich, Price = $10, Preparation Time = 10 min
2. Salad: Price = $8, Preparation Time = 8 min
3. Soup: Price = $6, Preparation Time = 15 min
4. Coffee/tea: Price = $5, Preparation Time = 5 min
Discount
1. Sandwich: 10% if 5 Sandwich or more are ordered
2. Salad: 10% if Salad ordered with a Soup
3. Soup: 20% if Soup ordered with a Sandwich and a Salad
4. Coffee/tea: No
The Receipt should be printed as shown:
*************************************************
<Name>, thanks for your order
Items qty Price
Item 1 ## $$
Item 2 ## $$
Item 3 ## $$
Item 4 ## $$
Tax $$
Total $$$
<Date>, Your order will be ready in <time>
***************************************************
RestaurantOrderingApplication.py
# Peter Trinh | Extra Credit - 206.2 Restaurant Ordering Application | Prof. Serena Villalobos | 4/10/2024
import datetime
# class `RestaurantOrderingSystem` is a basic representation of a restaurant ordering system.
class RestaurantOrderingSystem:
# Initializes the RestaurantOrderingSystem with a predefined menu.
def __init__(self):
self.menu = {
1: {"name": "Sandwich", "price": 10, "prep_time": 10},
2: {"name": "Salad", "price": 8, "prep_time": 8},
3: {"name": "Soup", "price": 6, "prep_time": 15},
4: {"name": "Coffee/Tea", "price": 5, "prep_time": 5}
}
# Prints the receipt for the customer's order including itemized details and total.
def print_receipt(self, customer_name, order):
total_price = 0
total_prep_time = 0
# Calculate total price and preparation time based on the order
for item, quantity in order.items():
total_price += self.menu[item]["price"] * quantity
total_prep_time += self.menu[item]["prep_time"] * quantity
# Applying discounts
sandwich_count = order.get(1, 0)
salad_count = order.get(2, 0)
soup_count = order.get(3, 0)
if sandwich_count >= 5:
total_price -= round(sandwich_count * self.menu[1]["price"] * 0.1, 2)
if soup_count > 0 and salad_count > 0:
total_price -= round(self.menu[2]["price"] * 0.1, 2)
if soup_count > 0 and sandwich_count > 0 and salad_count > 0:
total_price -= round(self.menu[3]["price"] * 0.2, 2)
# Calculate CA 10% tax
tax = round(total_price * 0.10, 2)
# Calculate order ready time
current_time = datetime.datetime.now()
order_ready_time = current_time + datetime.timedelta(minutes=total_prep_time)
# Print the receipt
print("*************************************************")
print(f"{customer_name}, thanks for your order")
print()
print("Items qty Price")
for item, quantity in order.items():
item_name = self.menu[item]['name']
item_price = self.menu[item]['price']
print(f"{item_name} {quantity} ${round(item_price * quantity, 2)}")
print()
print(f"Tax ${tax}")
print(f"Total ${round(total_price + tax, 2)}")
print()
print(f"{current_time.strftime('%Y-%m-%d %H:%M:%S')}, Your order will be ready in {total_prep_time} min")
print("*************************************************")
# Create an instance of RestaurantOrderingSystem
ordering_system = RestaurantOrderingSystem()
# Take customer's order
customer_name = input("Please enter your name: ")
# Example order (50*0.9+8*0.9+6*0.8+0*1)*1.1=62.7
order = {}
for item_id, item_info in ordering_system.menu.items():
quantity = int(input(f"Please enter the quantity of {item_info['name']}: "))
order[item_id] = quantity
ordering_system.print_receipt(customer_name, order) # Print the receipt
Create a program that does the following:
Accepts 2 point values from the user in (x, y) format for the first line
Accepts 2 point values from the user in (x, y) format for the second line
Calculates and prints the slope-intercept form of the equation for each line
Generates a set of multiple points and plots a line for each equation
Informs the user if the system of linear equations is dependent, independent, or inconsistent
Example Output:
Enter 2 point values (x, y): 1, 4
The point (1,4) is the first point for line A.
Enter 2 more point values (x, y): -1, 8
The point (-1, 8) is the second point for line A.
Enter 2 point values (x, y): -2, 6
The point (-2, 6) is the first point for line B.
Enter 2 more point values (x, y): 2, 18
The point (2, 18) is the second point for line B.
Line A: y = -2x + 6
Line B: y = 3x + 12