Anonymous
timer Asked: Apr 10th, 2020

Question Description

1) Open file "baby2014.txt" and print the contents of this file.

a) define a function to print the first 10 original lines of the file.
b) define a function to print the last 10 original lines of the file.

2) Open file "baby2014.txt" and store the contents of this file in Python "list".

a) define a function to store the first 10 "entries" into a Python "List" as:
[ [name0, gender0, number0], [name1, gender1, number1], [name2, gender2, number2], ... []]
b) Print the created List.

3) Open file "baby2014.txt" and store the contents of this file in Python "Dictionary".

a) define a function to store the 20th to 30th "entries" into a Python "Dictionary".
Using name as key and number as value as:
{name0: number0, name1: number1, name2: number2, ...}
b) print the created dictionary.

4) Using the info (name, gender, number) in "baby2014.txt" file design a class to store them as "Account" data.

Create a class named 'Account' with the following attributes and methods:
- Attributes in class "Account":
-- name,
-- gender,
-- balance, this filed needs to be private (no direct access).

- methods:
a) __init__():
This is the default initialization method which allows no
passing arguments to create.

b) __str__(): provides info to print all attributes of the account.
c) get_balance() and,
d) set_balance().

In the major program, create ONLY 5 accounts is good enough for this exercise. (any 5 entries in the "baby2014.txt" file)

e) Once these 5 accounts created, print the account info out,
as "name", "gender", and "balance".

f) use try-except handling to handle the direct access exception
of the "balance" attribute in class "Account".

g) The Bank is providing an extra $100 bonus to these 5 accounts.
Please update their account balances in their accounts.
print out the updated account info for these 5 accounts.

5) Using the information (name, gender, and number) in
"baby2014.txt" file, create a class "LinkNode" and use single linked list to store them.

Create a class named 'LinkNode' with the following attributes and methods:
- Attributes in Class Node:
-- name,
-- gender,
-- data,
-- next.

- methods:
a) __init__():
This is the default initialization method which allows no
passing arguments to create.

b) __str__(): provides info to print all attributes of the "LinkNode".

Create a single linked list class "Sllist" with the following
attributes:
-- head,
-- length,

- methods:
c) __init__():
d) add():
e) find():
using the "name" field to identify the existence of the "LinkNode".
Test to find an entry with the same “name” on the “Sllist”.
Find one existing name and find one name which is not on the
"Sllist".

f) delete():
delete the "LinkNode" with the same "name" attribute.
Test to delete an entry with “name” on the “Sllist”.
Delete one existing name and delete one name which is not on the
"Sllist".

g) __str__():
The build-in function to print out "LinkNodes" in the linked list "Sllist".

h) store 10 "LinkNodes" in the "Sllist" list is good enough.
i) once stored the "LinkNode" info, print them out.
j) then test “find()” (part e) and “delete()” (part f).

6) Using the information (name, gender, and number) in
"baby2014.txt" file, create a class "TreeNode" and use "binary tree" to store them.

Create a class named 'TreeNode' with the following attributes and methods:
- Attributes in Class 'TreeNode':
-- name,
-- gender,
-- data
-- left,
-- right.

- methods:
a) __init__():
This is the default initialization method which allows no
passing arguments to create.

b) __str__(): provides info to print all attributes of the "TreeNode".

Create a binary tree class "Tree" with the following
attributes:
-- root,

- methods:
c) __init__():
This is the default initialization method which allows no
passing arguments to create.
d) add():
e) find():
using the "name" field to identify the existance of the "TreeNode".
Test to find an entry with the same “name” on the “Tree”.
Find one existing name and find one name which is not on the
"Tree".

f) Please explain what piece of info is needed to have delete()
method in "Binary Tree".

g) __str__(): provides info to print all attributes of the "TreeNode".

h) store 10 "TreeNodes" in the "Tree" is good enough.
i) once stored the "TreeNode" info, print them out.
j) then test “find()” (part e).


7) A product uses the following pattern as "product key" to
validate the "genuine copy of the software":
QWER-56AS-1234 (as example).

Please write a Python program using random number and letter generators to generate 5 of these "product keys".

Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors