Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# Coding for Veterans: Intermediate Python Assignment 1 # By: Mike Mawson # Due Date: 12 July 2020 # Finished: 11 July 2020 # Imports import csv def user_input(): choice = input('\nPlease choose...

1 answer below »
# Coding for Veterans: Intermediate Python Assignment 1
# By: Mike Mawson
# Due Date: 12 July 2020
# Finished: 11 July 2020
# Imports
import csv
def user_input():
choice = input('\nPlease choose operation: \n \n 1 : Enter car details \n 2 : Exit')
if choice == '1':
XXXXXXXXXXmake = input("Enter car make: ")
XXXXXXXXXXmodel = input("Enter car model: ")
XXXXXXXXXXyear = int(input("Enter car year: "))
XXXXXXXXXXperson = input("Enter sales person: ")
XXXXXXXXXXprice = float(input("Enter sales price: "))
XXXXXXXXXXcar_details = {'Car Make': make, 'Car Model': model, 'Car Year': year,
'Sales Person': person, 'Sales Price': price}
XXXXXXXXXXreturn car_details
# if user chooses 2, exit program
elif choice == '2':
XXXXXXXXXXreturn {}
else:
XXXXXXXXXXraise Exception
while True:
try:
# Take user input
XXXXXXXXXXcar_details = user_input()
XXXXXXXXXXif car_details:
# Read file and add details to it
XXXXXXXXXXwith open('carSales.csv', mode='a') as csv_file:
XXXXXXXXXXfieldnames = ['Car Make', 'Car Model','Car Year','Sales Person','Sales Price']
XXXXXXXXXXwriter = csv.DictWriter(csv_file, fieldnames=fieldnames)
XXXXXXXXXXwriter.writerow(car_details)
XXXXXXXXXXprint('Car Details Entered Successfully.\n')
XXXXXXXXXXelse:
XXXXXXXXXXprint('Exiting Program. Thank You.')

eak
except IOE
or:
XXXXXXXXXXprint("I/O e
or: E
or while opening CSV file.")

eak
except (TypeE
or, ValueE
or):
XXXXXXXXXXprint('Enter co
ect values. Try Again.')
XXXXXXXXXXcontinue
except Exception as e:
XXXXXXXXXXprint('Please choose co
ect option.')
XXXXXXXXXXcontinue

Intermediate Python
Assignment 4
Due Date: December 15st by 11:30PM
The objective of every assignment is to make sure you practice what we learned throughout the
modules to cement your learning. Every assignment is based on a real-life scenario to prepare
you for a job in the industry. Assignment 4 covers topics that we will cover in modules 5,6, and
7.
The car dealership from Assignment 1 is not happy with the Python console-based application
that you have created and would like to upgrade a few features.
Instead of utilizing the Python console to input the information, they would like their employees
to have a GUI to enter the exact same information from assignment 1. Additionally, the
dealership no longer wants to rely on a CSV file and wants to upgrade the program so that it
stores all the information on a database.
You must create text fields with labels (e.g., Car Make) so that the car dealership employee can
input the relevant information. You must also create a submit button; that when clicked, the data
is saved to a local database created in PHPMyAdmin. This means that you need to create a
database table with the appropriate columns.
Just like Assignment 3, you must screenshot the database table after you have added information
to it using your Python program to prove that the program works!
Deliverables:
• Commented Python code file (.py)
• Screenshot of the database (.png or .jpeg)
• Screenshot of your git logs to prove that you have been utilizing git to backup your code
throughout the development process.
• As always, your files must be zipped into one zip file named
studentNumber_studentName_Assignment4 and submitted via D2L by the deadline.
Answered Same Day Jul 29, 2021

Solution

Sanghamitra answered on Jul 31 2021
141 Votes
62551/assignment4.py
import tkinter as tk
from tkinter import ttk
import mysql.connecto
#mysql database connection
db = mysql.connector.connect(
host='localhost',
user='root',
password='',
db='car_dealership'
)
#Cursor
cursor = db.cursor()
class Example:
def __init__(self):

#setup the window default property
window.title('Intermediate Python::Assignment 4')
window.geometry('500x400')
window.wm_minsize(150, 150)

#render form in window starts here
self.save_btn = ttk.Button(window, text='Save', command=self.save)
self.save_btn.place(x=400, y=365)
# Labels ------------------------------------------
self.make = ttk.Label(window, text='Enter car make:', width=90)
self.make.place(x=5, y=50 )
self.model = ttk.Label(window, text='Enter car model:')
self.model.place(x=5, y=100)
self.year = ttk.Label(window, text='Enter car year:',width=20)
self.year.place(x=5, y=150)

self.person = ttk.Label(window, text='Enter sales person:')
self.person.place(x=5, y=200)

self.price = ttk.Label(window,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here