
Concept explainers
In python code:
Using the dataframe produced in question#2 and your
class GreenhouseGas(NamedTuple):
Gas: str
Pre_1750: float
Recent: float
Absolute_increase_since_1750: float
Percentage_increase_since_1750: float
def __repr__(self):
return f"Gas: {self.Gas}, Pre-1750: {self.Pre_1750}, Recent: {self.Recent}, Absolute increase since 1750: {self.Absolute_increase_since_1750}, Percentage increase since 1750: {self.Percentage_increase_since_1750}"
def __lt__(self, other):
return self.Recent < other.Recent
def __eq__(self, other):
return self.Gas == other.Gas
@classmethod
def from_list(cls, data):
gas, pre_1750, recent, absolute_increase, percentage_increase = data
return cls(gas, pre_1750, recent, absolute_increase, percentage_increase)
def search_gas(gas_list, gas_name):
for gas in gas_list:
if gas.Gas == gas_name:
return gas
return None
gas_list = [
GreenhouseGas.from_list(["Gas1", 1.0, 2.0, 3.0, 4.0]),
GreenhouseGas.from_list(["Gas2", 5.0, 6.0, 7.0, 8.0]),
GreenhouseGas.from_list(["Gas3", 9.0, 10.0, 11.0, 12.0]),
]
# sort the list by Recent
gas_list.sort()
# search for a specific gas
result = search_gas(gas_list, "Gas2")
print(result)
class Database:
def __init__(self, dbName):
self.dbName = dbName
def connect(self):
global sqliteConnection
try:
sqliteConnection = sqlite3.connect(self.dbName)
cursor = sqliteConnection.cursor()
print("Database created and Successfully Connected to SQLite")
select_Query = "select sqlite_version();"
cursor.execute(select_Query)
record = cursor.fetchall()
except sqlite3.Error as error:
print("Error while connecting to sqlite", error)
def table(self, query):
global sqliteConnection
try:
cursor = sqliteConnection.cursor()
cursor.execute(query)
sqliteConnection.commit()
print("SQLite table created")
except sqlite3.Error as error:
print("Table exists: ", error)
def insert(self, query, df):
global sqliteConnection
try:
cursor = sqliteConnection.cursor()
for row in df.itertuples():
insert_sql = query.format(row[0], row[1])
cursor.execute(insert_sql)
sqliteConnection.commit()
print("Inserted successfully into table")
except sqlite3.Error as error:
print("Failed to insert: ", error)
def search(self, query, value):
global sqliteConnection
cursor = sqliteConnection.cursor()
sel = query.format(value)
cursor.execute(sel)
result = cursor.fetchall()
return result[0][0]
def delete(self, query, id):
global sqliteConnection
try:
cursor = sqliteConnection.cursor()
delete_query = query + str(id)
cursor.execute(delete_query)
sqliteConnection.commit()
print("Record deleted successfully ")
except sqlite3.Error as error:
print("Failed to delete record from sqlite table", error)
def query_builder(self, name, qType, colandType, dataType=[]):
col = list(colandType)
types = list(colandType.values())
if qType == ("TABLE" or "table" or "Table"):
query = f"CREATE TABLE IF NOT EXISTS {name} "
for i in range(len(col)):
if col[i] == col[-1]:
query += f"{col[i]} {types[i]})"
else:
query += f"({col[i]} {types[i]}, "
elif qType == ("INSERT" or "insert" or "Insert"):
query = f"INSERT INTO {name} "
for i in range(len(col)):
if col[i] == col[-1]:
query += f"{col[i]}) VALUES "
else:
query += f"({col[i]}, "
for i in range(len(col)):
if col[i] == col[-1]:
query += "{})"
else:
query += "({}, "
elif qType == ("SELECT" or "select" or "Select"):
query = f"SELECT {dataType[1]} FROM {name} WHERE {dataType[0]} == " + "'{}'"
elif qType == ("DELETE" or "delete" or "Delete"):
query = f"DELETE from {name} WHERE {dataType} = "
return query

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

- Which example uses the SOLID SRP principle correctly and does not violate it? (A or B) A. public class DatabaseParser { ParseDirectoryMapFile(); // parse directory map fileParsePasswordFile(); // parse user fileParseReviewDataFile(); // parse review data fileParseTeamFile(); // parse team CalculateGrade(); CalulateRelativeGrade(); } B public class DatabaseParser { ParseDirectoryMapFile(); // parse directory map fileParsePasswordFile(); // parse user fileParseReviewDataFile(); // parse review data fileParseTeamFile(); // parse team file} // seperately with the following: public class Calculator{ CalculateGrade(); CalulateRelativeGrade(); }arrow_forwardThe code given below represents a saveTransaction() method which is used to save data to a database from the Java program. Given the classes in the image as well as an image of the screen which will call the function, modify the given code so that it loops through the items again, this time as it loops through you are to insert the data into the salesdetails table, note that the SalesNumber from the AUTO-INCREMENT field from above is to be inserted here with each record being placed into the salesdetails table. Finally, as you loop through the items the product table must be update because as products are sold the onhand field in the products table must be updated. When multiple tables are to be updated with related data, you should wrap it into a DMBS transaction. The schema for the database is also depicted. public class PosDAO { private Connection connection; public PosDAO(Connection connection) { this.connection = connection; } public void…arrow_forwardWrite a C#program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string) ClassRegistration -…arrow_forward
- /* Created with SQL Script Builder v.1.5 */ /* Type of SQL : SQL Server */ CREATE TABLE EMPLOYEE ( EMP_CODE int, EMP_TITLE varchar(4), EMP_LNAME varchar(15), EMP_FNAME varchar(15), EMP_INITIAL varchar(1), EMP_DOB datetime, JOB_CODE varchar(5), STORE_CODE int ); INSERT INTO EMPLOYEE VALUES('1','Mr.','Williamson','John','W','5/21/1964','SEC','3'); INSERT INTO EMPLOYEE VALUES('2','Ms.','Ratula','Nancy','','2/9/1969','MGR','2'); INSERT INTO EMPLOYEE VALUES('3','Ms.','Greenboro','Lottie','R','10/2/1961','GEN','4'); INSERT INTO EMPLOYEE VALUES('4','Mrs.','Rumpersfro','Jennie','S','6/1/1971','GEN','5'); INSERT INTO EMPLOYEE VALUES('5','Mr.','Smith','Robert','L','11/23/1959','GEN','3'); INSERT INTO EMPLOYEE VALUES('6','Mr.','Renselaer','Cary','A','12/25/1965','GEN','1'); INSERT INTO EMPLOYEE VALUES('7','Mr.','Ogallo','Roberto','S','7/31/1962','MGR','3'); INSERT INTO EMPLOYEE VALUES('8','Ms.','Johnsson','Elizabeth','I','9/10/1968','SEC','1'); INSERT INTO EMPLOYEE…arrow_forwardjava program For this question, the server contains the id, name and cgpa of some Students in a file. The client will request the server for specific data, which the server will provide to the client. Server: The server contains the data of some Students. For each student, the server contains id, name and cgpa data in a file. Here's an example of the file: data.txt101 Saif 3.52201 Hasan 3.81.... Create a similar file in you server side. The file should have at least 8 students. The client will request the server to provide the details (id, name, cgpa) of the Nth highest cgpa student in the file. If N's value is 1, the server will return the details of the student with the highest cgpa. if N's value is 3, the server will return the details of the student with the third highest cgpa. If N's value is incorrect, the server returns to the client: "Invalid request". Client: The client sends the server the value of N, which is an integer number. The client takes input the value of N…arrow_forwardwrite in c++Write a program that would allow the user to interact with a part of the IMDB movie database. Each movie has a unique ID, name, release date, and user rating. You're given a file containing this information (see movies.txt in "Additional files" section). The first 4 rows of this file correspond to the first movie, then after an empty line 4 rows contain information about the second movie and so forth. Format of these fields: ID is an integer Name is a string that can contain spaces Release date is a string in yyyy/mm/dd format Rating is a fractional number The number of movies is not provided and does not need to be computed. But the file can't contain more than 100 movies. Then, it should offer the user a menu with the following options: Display movies sorted by id Display movies sorted by release date, then rating Lookup a release date given a name Lookup a movie by id Quit the Program The program should perform the selected operation and then re-display the menu. For…arrow_forward
- Written in Python It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method. Docstrings for modules, functions, classes, and methodsarrow_forwardFor this assignment, you are to use the started code provided with QUEUE Container Adapter methods and provide the implementation of a requested functionality outlined below. Scenario: A local restaurant has hired you to develop an application that will manage customer orders. Each order will be put in the queue and will be called on a first come first served bases. Develop the menu driven application with the following menu items: Add order Next order Previous order Delete order Order Size View order list View current order Order management will be resolved by utilization of an STL-queue container’s functionalities and use of the following Queue container adapter functions: enQueue: Adds the order in the queue DeQueue: Deletes the order from the queue Peek: Returns the order that is top in the queue without removing it IsEmpty: checks do we have any orders in the queue Size: returns the number of orders that are in the queue While adding a new order in the queue, the program…arrow_forwardplease help me with this JAVA programming 1 assignment. You are creating a database of fey creatures found in Western Arkansas. Your data includes the creature's species, description, diet, and difficulty to catch. Include the following in your database: Species Description Diet Danger Level Times Caught Sprite Small winged humanoid berries medium 1 Goblin Common evil fey Omnivorous medium 5 Troll Large, dangerous, ugly humanoids high 1 Boggart Mischievous teleporting goblin-like creature stolen pies low 4 Gnome Small, shy, burrowing burrowing critters low 2 Dryad tree-maiden spirit tied to a forest unknown medium 0 Using one or more arrays, display this list. Modify the program so the user enters a number. Then, display all the creatures (and their info) who have been caught at least that many times. In addition to the above, allow the user to enter the name of a creature. If that creature is in the list, add one to the number of times that creature has been…arrow_forward
- In c++ Create a new project named lab9_2. You will continue to use the Courses class, but this time you will create a vector of Courses. The file you will read from is below: 6CSS 2A 1111 35CSS 2A 2222 20CSS 1 3333 40CSS 1 4444 33CSS 3 5555 15CSS 44 6666 12 Read this information into a vector of Courses. Then, print out a summary of your vector. Here's a sample driver: #include <iostream>#include <string>#include <fstream>#include <vector>#include <cstdlib>#include "Course.h"using namespace std;int main(){vector<Course> myclass;string dep, c_num;int classes, sec, num_stus;ifstream fin("sample.txt");if (fin.fail()){cout << "File path is bad\n";exit(1);}fin >> classes;for (int i = 0; i < classes; i++){fin >> dep >> c_num >> sec >> num_stus;// Now how do you create a Course object// that contains the information you just read in// and add it to your myclass vector?}cout << "Here are the college courses: "…arrow_forwardBuild an application for a car rental company. It should offer the following features:• Maintain a customer database in a file:o Register / add new customers. Customer information should include▪ Customer ID number▪ Name▪ Phone numbero Search customer database by:▪ Customer ID number▪ Name▪ Phone numberAnd print out the matching records NOTE ; i need the answer to be by switcharrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





