V

@Videonerd03

String Basics

Python
4 months ago
fav_flower1 = input() fav_flower2 = input() length_difference = len(fav_flower1) - len(fav_flower2) print(fav_flower2, "is", length_difference, "character(s) shorter than", fav_flower1) #read string full_name from input that consists of a three-letter first name, a space, and a last name. # Then assign first_name_initial with the first letter of the first name and last_name_inital with the first letter of the last name

Convert total_years to centuries, decades and years, finding the maximum number of centuries

Python
4 months ago
#Convert total_years to centuries, decades, and years, finding the maximum number of centuries, then decades, then years. # A century is 100 years. A decade is 10 years total_years = int(input()) num_centuries = total_years // 100 remaining_after_centuries = total_years % 100 num_decades = remaining_after_centuries // 10

Modulo (%) Practice

Python
4 months ago
# Given a number % and // can be used to get each digit. For a three-digit number # user_val like 927 ones_digit = user_val % 10 # 927 / 10 = 92 because 10 X 92 = 920 # Remainder 927 - 920 = 7 # Answer = 7

Pythons expressions

Python
4 months ago
GRAVITATIONAL_CONSTANT = 6.673e-11 MASS_OF_EARTH = 5.98e+24 distance_center = float(input()) gravity_acceleration = (GRAVITAITONAL_CONSTANT * MASS_OF_EARTH) (/ distance_center ** 2) print(f'Acceleration of gravity: {gravity_acceleration:.2f}')

Numeric types: Floating-point

Python
4 months ago
#Complete the program to output 'Surface area is ' followed by the value of cube_area to five digits after the decimal point # Ex: if the input is 1.4000, then the output is: # Surface area is 11.76000 # Note print (f' {my_float:.xf}') outputs my_float to X digits after the decimal point cube_edge = float(input()) cube_area = 6.0 * (cube_edge * cube_edge)

Experimenting with objects

Python
4 months ago
# List of birthdays birthdays = [ {"year": 1986, "month": "April", "day": 22}, {"year": 1990, "month": "December", "day": 25}, {"year": 2000, "month": "July", "day": 4}, {"year": 1995, "month": "January", "day": 1} ] # dictionary of holidays ( Month -> list of days)

Salary Calculator

Python
4 months ago
hourly_wage = 20 print('Annual salary is: ') print(hourly_wage * 40 * 50) print() print('Monthly salary is: ') print((hourly_wage * 40 *50) / 12)) print()

Write one input() statement

Python
4 months ago
names_list = [] for i in range(3): # read 3 names first_name = input("Enter first name: ") last_name = input("Enter last name: ") names_list.append(f"{first_name} - {last_name}") print(names_list)

Read user input and print to output

Python
4 months ago
num1 = int(input()) num2 = int(input()) num3 = int(input()) print(num1 * num2 * num3)

Basic input

Python
4 months ago
human_years = int(input('Enter age of dog (in human years): 10')) print() dog_years = 7 * human_years print(human_years, 'human years is about', end=' ') print(dog_years, 'dog years.')

DVD database

MySQL
4 months ago
CREATE OR REPLACE FUNCTION fn_customer_status(status TEXT) RETURNS TEXT LANGUAGE plpgsql AS $$ BEGIN IF status = 'Y' THEN RETURN 'Active'; ELSEIF status = 'N' THEN RETURN 'Inactive'; ELSE

invoice

MySQL
7 months ago
CREATE TABLE Customer ( CustomerID MEDIUMINT AUTO_INCREMENT PRIMARY KEY, First_Name VARCHAR(200) NOT NULL, Last_Name VARCHAR(200) NOT NULL ); CREATE TABLE Invoice( OrderID MEDIUMINT AUTO_INCREMENT PRIMARY KEY,

Brainy like that

MySQL
7 months ago
CREATE TABLE pages ( page_id INT PRIMARY KEY, page_name VARCHAR(255) ); CREATE TABLE page_likes ( user_id INT, page_id INT, liked_date DATETIME, FOREIGN KEY(page_id) REFERENCES pages(page_id)

Practice code with CHATT

MySQL
7 months ago
CREATE TABLE Products( ProductID MEDIUMINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, ProductName VARCHAR(150) NOT NULL, UnitPrice DECIMAL(5,2), StockQuantity MEDIUMINT UNSIGNED ); CREATE TABLE Customers( CustomerID MEDIUMINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, CustomerName VARCHAR(150) NOT NULL,

Challenge D427

MySQL
7 months ago
-- Write a SQL statement to ensure that customerID in the invoice is a foreign key referencing ID in the customer table. -- If a customer is deleted we want to the invvoice to also be deleted ALTER TABLE Invoice ADD CONSTRAINT fk_CustomerID FOREIGN KEY (CustomerID) REFERENCES Customer(ID) ON DELETE CASCADE;

Problem 5

MySQL
7 months ago
CREATE TABLE Transaction ( OrderID SMALLINT UNSIGNED, ProductID SMALLINT UNSIGNED, Quantity TINYINT UNSIGNED CHECK(Quantity <= 100), AmountSpent DECIMAL(6,2) UNSIGNED, FOREIGN KEY(OrderID) REFERENCES Invoice(OrderID), FOREIGN KEY(ProductID) REFERENCES Stock(ProductID) );

ADD CONSTRAINT

MySQL
7 months ago
-- Add a constraint for rating to ensure rating in the program table are between 0 and 5 Call the constraint rating check ALTER TABLE Program ADD CONSTRIANT rating_check CHECK(rating >= 0 AND Rating =< 5);

Problem #1

MySQL
7 months ago
CREATE TABLE Registration ( Registration_ID MEDIUMINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, Student_ID SMALLINT UNSIGNED, Course_ID TINYINT UNSIGNED, Status VARCHAR(15)CHECK(Status IN 'Enrolled','Completed', 'Dropped')) NOT NULL, Registration_Date DATE NOT NULL CHECK(Registration_Date >= '2020-01-01'), FOREIGN KEY(Student_ID) REFERENCES Student(ID) ON DELETE CASCADE, FOREIGN KEY(Course_ID) REFERENCES Course(Course_ID) ON DELETE CASCADE );

Index

MySQL
7 months ago
-- Primary Key Index -- automatically creates a unique index on the column -- Depends on the storage engine -- Clustered Index (primary index ) -- Stores the actual row data in the same structure as the index -- Can be only one clustered index per table because the data rows themselves are stored -- in order of the index -- Uses primary key as the clustered index by default.

Practice codeeeee

MySQL
7 months ago
CREATE TABLE Instructor ( ID INT PRIMARY KEY, Name VARCHAR(100), Department VARCHAR(100) ); CREATE TABLE Course ( ID INT PRIMARY KEY, Title VARCHAR(150),