π
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
Below is the SQL solution for the given airline schema with complete explanations for each query: | |
a) Create Tables with Primary Keys and Foreign Keys | |
CREATE TABLE Flights ( | |
flno INTEGER PRIMARY KEY, | |
from_city VARCHAR(50), | |
to_city VARCHAR(50), | |
distance INTEGER, | |
departs TIME, |
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
Here is the solution for the Sailors database schema: | |
a) Create the tables by specifying primary keys and foreign keys: | |
CREATE TABLE Sailors ( | |
sid INTEGER PRIMARY KEY, | |
sname VARCHAR(50), | |
rating INTEGER, | |
age REAL | |
); |
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
Here is a simpler explanation and approach for the selected SQL tasks: | |
c) Find aircraft names where all pilots certified to operate them earn more than 80,000 | |
Simplified Query: | |
SELECT a.aname | |
FROM Aircraft a | |
JOIN Certified c ON a.aid = c.aid | |
JOIN Employees e ON c.eid = e.eid |
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
1.StarCase | |
# Read the size of the staircase | |
n = int(input()) | |
# Loop to build the staircase | |
for i in range(n): | |
# Calculate the number of leading spaces and # symbols | |
spaces = ' ' * (n - i - 1) # Number of spaces | |
hashes = '#' * (i + 1) # Number of hashes | |
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 | |
from datetime import datetime | |
# Log an event with the current timestamp | |
def log_event(event): | |
current_timestamp = time.time() # Get the timestamp | |
readable_time = datetime.fromtimestamp(current_timestamp).strftime("%Y-%m-%d %H:%M:%S") | |
print(f"[{readable_time}] Event: {event}") | |
# Example usage |
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
# Get the current datetime | |
now = datetime.now() | |
# Format it into a readable string | |
formatted_date = now.strftime("%Y-%m-%d %H:%M:%S") | |
print("Formatted Date:", formatted_date) |
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
# Create a datetime object | |
dt = datetime(2024, 12, 4, 15, 0, 0) | |
# Convert datetime to timestamp | |
timestamp = dt.timestamp() | |
print("Timestamp:", timestamp) |
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 datetime import datetime | |
# Example timestamp | |
example_timestamp = 1701739200 # Example: Dec 4, 2024 | |
# Convert timestamp to datetime | |
converted_datetime = datetime.fromtimestamp(example_timestamp) | |
print("Readable Date and Time:", converted_datetime) |
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 | |
# Get the current timestamp | |
current_timestamp = time.time() | |
print("Current Timestamp (seconds since epoch):", current_timestamp) |