CPT 180 Chapter 8 (1st Edition) – Chapter 9 (2nd Edition) Assignment 1 Directions Using the following guidelines, create a python program. 1. Download the file CPT180Stuff.zip. 2. Extract this file...

1 answer below »
I need a python code for these 2 assignments.


CPT 180 Chapter 8 (1st Edition) – Chapter 9 (2nd Edition) Assignment 1 Directions Using the following guidelines, create a python program. 1. Download the file CPT180Stuff.zip. 2. Extract this file into the root directory of one of your computer's drives. For example, you could extract it on your C: drive or on to a USB drive such as E: drive. You should now have a folder named CPT180Stuff located in your selected location. (If using a Mac, copy the downloaded zip file to your documents folder. Extract the files here.) 3. Create a program named workWithFiles.py. 4. Add three comment lines at the top of the program that contain: a. Program Name b. Program Description c. Programmer's Name (You) 5. Write code that will do the following: a. Print out the name of the current working directory. b. Change the current working directory to the CPT180Stuff folder. c. Print out the name of the current working directory. d. Create a new folder in the CPT180Stuff folder with the name "cellphones". In your code, check and ensure that the folder does not already exist prior to attempting to create it. e. Print out the contents of the CPT180Stuff folder as shown in Example Output. f. Print out the contents of the CPT180Stuff\cars folder as shown in Example Output. g. Print out the contents of the CPT180Stuff\pets folder as shown in Example Output. h. Print out the contents and file sizes of the CPT180\pets\cats folder as shown in the Example Output. i. Print out the contents and file sizes of the CPT180\pets\dogs folder as shown in the Example Output. 6. Submit the workWithFiles1.py file into the Chapter 8-9 Assignment 1 Submission Folder. Example Output CPT 180 Chapter 8 (1st Edition) – Chapter 9 (2nd Edition) Assignment 2 Directions Using the following guidelines, create a python program. 1. You will be using the CPT180Stuff folder from Assignment 1 for this assignment. 2. Create a program named workWithFiles2.py. 3. Add three comment lines at the top of the program that contain: a. Program Name b. Program Description c. Programmer's Name (You) 4. Write code that will do the following: a. Using an if statement, determine if both the dognames.txt file and the catnames.txt file exist. If both files exist, the program should complete steps b – m below. If either file does not exist, the program should print out the message "Unable to access one or more files". b. Open the file named dognames.txt in the CPT180Stuff\pets\dogs folder in the read mode. c. Print the contents of the file. d. Close the file. e. Open the file named catnames.txt in the CPT180Stuff\pets\cats folder in the read mode. f. Print the contents of the file. g. Close the file. h. Open the catnames.txt file in the append mode. i. Add two cat names to the file. You can pick the names. The example output below shows the names Mortimer and Tigger added. j. Close the file. k. Open the catnames.txt file in read mode. l. Print the contents of the file. m. Close the file. 5. Submit the workWithFiles2.py file into the Chapter 8 - 9 Assignment 2 Submission Folder. Hints 1. Ensure to add the newline character at the end of each name added to the file. Example Output
Answered Same DayJul 21, 2021

Answer To: CPT 180 Chapter 8 (1st Edition) – Chapter 9 (2nd Edition) Assignment 1 Directions Using the...

Sanghamitra answered on Jul 21 2021
139 Votes
Python/Assignment1/CPT180Stuff/cars/familycars/familycars.jpg
Python/Assignment1/CPT180Stuff/cars/familycars/familycars.txt
Chevrolet Impala
Honda Accord
Ford Taurus
Kia Optima
Voltswagon Jetta
Chrysler 300
Python/Assignment1/CPT180Stuff/cars/sportscars/sportscars.jpg
Python/Assignment1/CPT180Stuff/cars/sportscars/sportscars.txt
Ford Mustang
Chevrolet Corvette
Pontiac GTO
Oldsmobile 442
Porsche 911
Dodge Charger
Python/Assignment1/CPT180Stuff/cpt180.txt
Trident Technical College
CPT 180
Shell Scripting
3 Credit Hours
Python/Assignment1/CPT180Stuff/pets/cats/catnames.txt
Misty
Felix
Fluffy
Kimba
Tom
Python/Assignment1/CPT180Stuff/pets/cats/cats.jpg
Python/Assignment1/CPT180Stuff/pets/dogs/dognames.txt
Spot
Max
Lassie
Rover
Snoopy
Python/Assignment1/CPT180Stuff/pets/dogs/dogs.jpg
Python/Assignment1/workWithFiles.py
"""
Program:Assignment1
Program Description:Working with files & file path concepts
@author: Derrick
"""
#a. Print out the name of the current working directory.
#RESTART
from pathlib import Path
import os
'''
Get Current working Directory
'''
currentDirectory = Path.cwd()

print(currentDirectory)
'''
Change the Current working Directory
'''
os.chdir('F:/Python/CPT180Stuff')

'''
Print Current working Directory
'''
currentDirectory2 = Path.cwd()

print(currentDirectory2)
'''
Print out the contents of the CPT180Stuff\cars folder as shown in Example Output
Create a new folder in the CPT180Stuff folder with the name "cellphones".
In your code, check and ensure that the folder...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here