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))
Need a different function for the python
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb12e7222-506e-487d-a20e-061b70f8136b%2F8cfd03fa-29c9-43e8-9fc0-75b0688a897e%2F6262jm_processed.png&w=3840&q=75)
![.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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb12e7222-506e-487d-a20e-061b70f8136b%2F8cfd03fa-29c9-43e8-9fc0-75b0688a897e%2Fp1vtlnq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Q1. The last post didnt include the items in the
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.](https://content.bartleby.com/qna-images/question/b12e7222-506e-487d-a20e-061b70f8136b/cd9ea0db-6387-4666-b4e7-d8fde391ff80/tagy16_thumbnail.png)
![.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.](https://content.bartleby.com/qna-images/question/b12e7222-506e-487d-a20e-061b70f8136b/cd9ea0db-6387-4666-b4e7-d8fde391ff80/b40s7z9_thumbnail.png)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)