Need a different function for the python program display_ticket  def display_tickets(): t = Texttable() tickets=cur.execute('''SELECT * FROM tickets''') for i in tickets: t.add_rows([['tid', 'actual_speed','posted_speed','age','violator_sex'],list(i)]) print() print(t.draw()) print() Need a different function for the python program add_ticket    def add_tickets(): actual_speed=int(input("enter actual speed:")) posted_speed=int(input("enter posted speed:")) age=int(input("enter age:")) sex=input("Male or Female:") cur.execute('''INSERT INTO tickets(actual_speed,posted_speed,age,violator_sex) VALUES(?,?,?,?)''',(actual_speed,posted_speed,age,sex))

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Need a different function for the python program display_ticket 

def display_tickets():
t = Texttable()
tickets=cur.execute('''SELECT * FROM tickets''')
for i in tickets:
t.add_rows([['tid', 'actual_speed','posted_speed','age','violator_sex'],list(i)])
print()
print(t.draw())
print()

Need a different function for the python program add_ticket 

 

def add_tickets():
actual_speed=int(input("enter actual speed:"))
posted_speed=int(input("enter posted speed:"))
age=int(input("enter age:"))
sex=input("Male or Female:")
cur.execute('''INSERT INTO tickets(actual_speed,posted_speed,age,violator_sex) VALUES(?,?,?,?)''',(actual_speed,posted_speed,age,sex))
con.commit()

If you'd like to see what thousands of traffic tickets look like, check out this link: https://www.twincities.com/2017/08/11/we-analyzed-224915-minnesota-speeding-tickets-see-what-we-learned/

We have looked at a variety of ways to store information using Python. But a company of any size does not
use text files, or pickle things. They use, in almost all case, a relational database management system. We
are going to use sqlite3 for this assignment, and it will do just fine for the amount of data we intend to
Global
NO
Variables
wrangle.
The database for this assignment is named tickets5.db. The tickets5.db will be provided as a zipped file later on this page. The
database has a little over 20 records, all of which started out as part of a database put together in Minnesota that cataloged
speeding tickets issued in 2014. The original database had thousands of records. I have whittled it down for this assignment to
about 22 simplified records. The table holding these records is named tickets. The first rows look like this.
Table:
tickets
tid
actual_speed
posted_speed
age
violator_sex
Filter Filter
Filter
Filter Filter
1
1
95
70
20 Female
95
70
25 Male
3
76
55
25 Male
4
4
77
60
27 Male
5
83
70
51 Female
The tickets table has these 5 fields. Do not modify the database name, the table structure, or modify the column names; your
code should work with my copy of the database.
• tid is an auto-incrementing primary key
• the next 3 fields: actual_speed, posted_speed and age, are all of type integer
the last field, violator_sex, is of type string.
Here is the link to the database. Unzip before using: tickets5.zip
Your program should be able to read the table in this database and be able to perform the following functions.
Menu options. Choose 1, 2, 3, or 4
1. Display all Tickets
2. Add a Ticket
3. Filter by Offender Sex
4. Save & Exit
Enter your choice, 1, 2, 3, or 4:
2.
Transcribed Image Text:We have looked at a variety of ways to store information using Python. But a company of any size does not use text files, or pickle things. They use, in almost all case, a relational database management system. We are going to use sqlite3 for this assignment, and it will do just fine for the amount of data we intend to Global NO Variables wrangle. The database for this assignment is named tickets5.db. The tickets5.db will be provided as a zipped file later on this page. The database has a little over 20 records, all of which started out as part of a database put together in Minnesota that cataloged speeding tickets issued in 2014. The original database had thousands of records. I have whittled it down for this assignment to about 22 simplified records. The table holding these records is named tickets. The first rows look like this. Table: tickets tid actual_speed posted_speed age violator_sex Filter Filter Filter Filter Filter 1 1 95 70 20 Female 95 70 25 Male 3 76 55 25 Male 4 4 77 60 27 Male 5 83 70 51 Female The tickets table has these 5 fields. Do not modify the database name, the table structure, or modify the column names; your code should work with my copy of the database. • tid is an auto-incrementing primary key • the next 3 fields: actual_speed, posted_speed and age, are all of type integer the last field, violator_sex, is of type string. Here is the link to the database. Unzip before using: tickets5.zip Your program should be able to read the table in this database and be able to perform the following functions. Menu options. Choose 1, 2, 3, or 4 1. Display all Tickets 2. Add a Ticket 3. Filter by Offender Sex 4. Save & Exit Enter your choice, 1, 2, 3, or 4: 2.
.Your program must have a main() function and separate functions to handle the display of all tickets, and the ability to add a
new ticket record to the tickets table. For option 3 your function should allow the user to enter either 'Male' or 'Female' and
then have your code filter the tickets table and show either all the Male offenders or all of the Female offenders.
When data is printed it all the data should be properly aligned and look neat. Whether you are printing all the tickets or only
part of them, your output should display this information: ticketID, Posted MPH, MPH Over, Age, and Violator Sex.
ticketID
Posted MPH
MPH Over
Age Violator Sex
2
70
25
25
Male
3
55
21
25
Male
4
60
17
27
Male
and so on
It is important to note that the original table has Posted MPH (posted_speed) and actual_speed. You must calculate and display
the MPH over the posted speed limit rather than displaying the actual_speed itself
mph over
= actual speed
posted speed.
For example the ticket associated with tid = 1 was doing 95 in a 70mpg zone, so miles over is 95 - 70 = 25.
There are programs similar to this assignment in week 12, More Data, and week 13, Classes 1. Study these examples carefully
before starting to code. In particular there is an explicit hint near the end of the week 13 lecture notes that should be very
useful.
Transcribed Image Text:.Your program must have a main() function and separate functions to handle the display of all tickets, and the ability to add a new ticket record to the tickets table. For option 3 your function should allow the user to enter either 'Male' or 'Female' and then have your code filter the tickets table and show either all the Male offenders or all of the Female offenders. When data is printed it all the data should be properly aligned and look neat. Whether you are printing all the tickets or only part of them, your output should display this information: ticketID, Posted MPH, MPH Over, Age, and Violator Sex. ticketID Posted MPH MPH Over Age Violator Sex 2 70 25 25 Male 3 55 21 25 Male 4 60 17 27 Male and so on It is important to note that the original table has Posted MPH (posted_speed) and actual_speed. You must calculate and display the MPH over the posted speed limit rather than displaying the actual_speed itself mph over = actual speed posted speed. For example the ticket associated with tid = 1 was doing 95 in a 70mpg zone, so miles over is 95 - 70 = 25. There are programs similar to this assignment in week 12, More Data, and week 13, Classes 1. Study these examples carefully before starting to code. In particular there is an explicit hint near the end of the week 13 lecture notes that should be very useful.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Q1. The last post didnt include the items in the database. Need a different function for the python program display_ticket below:

def display_tickets():
t = Texttable()
tickets=cur.execute('''SELECT * FROM tickets''')
for i in tickets:
t.add_rows([['tid', 'actual_speed','posted_speed','age','violator_sex'],list(i)])
print()
print(t.draw())
print()

Q2. Also need a different function for the python program add_ticket below:

def add_tickets():
actual_speed=int(input("enter actual speed:"))
posted_speed=int(input("enter posted speed:"))
age=int(input("enter age:"))
sex=input("Male or Female:")
cur.execute('''INSERT INTO tickets(actual_speed,posted_speed,age,violator_sex) VALUES(?,?,?,?)''',(actual_speed,posted_speed,age,sex))
con.commit()

If you'd like to see what thousands of traffic tickets look like, check out this link: https://www.twincities.com/2017/08/11/we-analyzed-224915-minnesota-speeding-tickets-see-what-we-learned/

We have looked at a variety of ways to store information using Python. But a company of any size does not
use text files, or pickle things. They use, in almost all case, a relational database management system. We
are going to use sqlite3 for this assignment, and it will do just fine for the amount of data we intend to
Global
NO
Variables
wrangle.
The database for this assignment is named tickets5.db. The tickets5.db will be provided as a zipped file later on this page. The
database has a little over 20 records, all of which started out as part of a database put together in Minnesota that cataloged
speeding tickets issued in 2014. The original database had thousands of records. I have whittled it down for this assignment to
about 22 simplified records. The table holding these records is named tickets. The first rows look like this.
Table:
tickets
tid
actual_speed
posted_speed
age
violator_sex
Filter Filter
Filter
Filter Filter
1
1
95
70
20 Female
95
70
25 Male
3
76
55
25 Male
4
4
77
60
27 Male
5
83
70
51 Female
The tickets table has these 5 fields. Do not modify the database name, the table structure, or modify the column names; your
code should work with my copy of the database.
• tid is an auto-incrementing primary key
• the next 3 fields: actual_speed, posted_speed and age, are all of type integer
the last field, violator_sex, is of type string.
Here is the link to the database. Unzip before using: tickets5.zip
Your program should be able to read the table in this database and be able to perform the following functions.
Menu options. Choose 1, 2, 3, or 4
1. Display all Tickets
2. Add a Ticket
3. Filter by Offender Sex
4. Save & Exit
Enter your choice, 1, 2, 3, or 4:
2.
Transcribed Image Text:We have looked at a variety of ways to store information using Python. But a company of any size does not use text files, or pickle things. They use, in almost all case, a relational database management system. We are going to use sqlite3 for this assignment, and it will do just fine for the amount of data we intend to Global NO Variables wrangle. The database for this assignment is named tickets5.db. The tickets5.db will be provided as a zipped file later on this page. The database has a little over 20 records, all of which started out as part of a database put together in Minnesota that cataloged speeding tickets issued in 2014. The original database had thousands of records. I have whittled it down for this assignment to about 22 simplified records. The table holding these records is named tickets. The first rows look like this. Table: tickets tid actual_speed posted_speed age violator_sex Filter Filter Filter Filter Filter 1 1 95 70 20 Female 95 70 25 Male 3 76 55 25 Male 4 4 77 60 27 Male 5 83 70 51 Female The tickets table has these 5 fields. Do not modify the database name, the table structure, or modify the column names; your code should work with my copy of the database. • tid is an auto-incrementing primary key • the next 3 fields: actual_speed, posted_speed and age, are all of type integer the last field, violator_sex, is of type string. Here is the link to the database. Unzip before using: tickets5.zip Your program should be able to read the table in this database and be able to perform the following functions. Menu options. Choose 1, 2, 3, or 4 1. Display all Tickets 2. Add a Ticket 3. Filter by Offender Sex 4. Save & Exit Enter your choice, 1, 2, 3, or 4: 2.
.Your program must have a main() function and separate functions to handle the display of all tickets, and the ability to add a
new ticket record to the tickets table. For option 3 your function should allow the user to enter either 'Male' or 'Female' and
then have your code filter the tickets table and show either all the Male offenders or all of the Female offenders.
When data is printed it all the data should be properly aligned and look neat. Whether you are printing all the tickets or only
part of them, your output should display this information: ticketID, Posted MPH, MPH Over, Age, and Violator Sex.
ticketID
Posted MPH
MPH Over
Age Violator Sex
2
70
25
25
Male
3
55
21
25
Male
4
60
17
27
Male
and so on
It is important to note that the original table has Posted MPH (posted_speed) and actual_speed. You must calculate and display
the MPH over the posted speed limit rather than displaying the actual_speed itself
mph over
= actual speed
posted speed.
For example the ticket associated with tid = 1 was doing 95 in a 70mpg zone, so miles over is 95 - 70 = 25.
There are programs similar to this assignment in week 12, More Data, and week 13, Classes 1. Study these examples carefully
before starting to code. In particular there is an explicit hint near the end of the week 13 lecture notes that should be very
useful.
Transcribed Image Text:.Your program must have a main() function and separate functions to handle the display of all tickets, and the ability to add a new ticket record to the tickets table. For option 3 your function should allow the user to enter either 'Male' or 'Female' and then have your code filter the tickets table and show either all the Male offenders or all of the Female offenders. When data is printed it all the data should be properly aligned and look neat. Whether you are printing all the tickets or only part of them, your output should display this information: ticketID, Posted MPH, MPH Over, Age, and Violator Sex. ticketID Posted MPH MPH Over Age Violator Sex 2 70 25 25 Male 3 55 21 25 Male 4 60 17 27 Male and so on It is important to note that the original table has Posted MPH (posted_speed) and actual_speed. You must calculate and display the MPH over the posted speed limit rather than displaying the actual_speed itself mph over = actual speed posted speed. For example the ticket associated with tid = 1 was doing 95 in a 70mpg zone, so miles over is 95 - 70 = 25. There are programs similar to this assignment in week 12, More Data, and week 13, Classes 1. Study these examples carefully before starting to code. In particular there is an explicit hint near the end of the week 13 lecture notes that should be very useful.
Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY