Questions
PYTHON Modify the program in section Ask the user for a first name and a last...

PYTHON

Modify the program in section

Ask the user for a first name and a last name of several people.

 Use a loop to ask for user input of each person’s first and last names

 Each time through the loop, use a dictionary to store the first and last names of that person

 Add that dictionary to a list to create a master list of the names

 Example dictionary:

aDict = { "fname":"Douglas", "name":"Lee" }

 Example master list, each element in the list is a dictionary:

namesList = [

{ "fname":"Douglas", "lname":"Lee" },

{ "fname":"Neil", "lname": "Armstrong" },

{ "fname":"Buzz", "lname":"Aldrin" },

{ "fname":"Eugene", "lname":"Cernan"},

{ "fname":"Harrison", "lname": "Schmitt"}

]

Pseudocode:

1) Ask for first name

2) Ask for last name

3) Create a dictionary with first name and last name

4) Add that dictionary to the master list object

5) If more names, go to (1)

6) If no more names, print the master list in a visually pleasing manner

In: Computer Science

Write a pseudocode for the following code: /*every item has a name and a cost */...

Write a pseudocode for the following code:

/*every item has a name and a cost */
public class Item {

   private String name;
   private double cost;
   public Item(String name, double cost) {
       this.name = name;
       this.cost = cost;
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public double getCost() {
       return cost;
   }
   public void setCost(double cost) {
       this.cost = cost;
   }   
}

public enum PaymentType {
   CASH,
   DEBIT_CARD,
   CREDIT_CARD,
   CHECK
}

/*every payment has a type and an amount*/

public class Payment {
   private double amount;
   private PaymentType paymentType;
   public Payment(double amount, PaymentType paymentType) {
       this.amount = amount;
       this.paymentType = paymentType;
   }
   public double getAmount() {
       return amount;
   }
   public void setAmount(double amount) {
       this.amount = amount;
   }
   public PaymentType getPaymentType() {
       return paymentType;
   }
   public void setPaymentType(PaymentType paymentType) {
       this.paymentType = paymentType;
   }   

In: Computer Science

I am working on making a simple gradebook. How it works is it asks user for...

I am working on making a simple gradebook. How it works is it asks user for name and grade. It does this for multiple instances until the person types quit to end the program. The code I have here works. My question is how do I print the output in alphabetical order?

Output from the input I put into my program:

David 98

Annabelle 87

Josh 91

Ben 95

What I want my code to do (in alphabetical order):

Annabelle87

Ben 95

David 98

Josh 91

Here is my code for the program:

grades = {}


def set_grade(name, grade):
grades[name] = grade


def print_grades_names():
for i in grades.keys():
print('{} {}'.format(i, str(grades[i])))

while True:
name = input("Enter a name (or 'quit' to stop): ")
if name == 'quit':
break
grade = input("Enter a grade: ")
set_grade(name, grade)


(print_grades_names())

In: Computer Science

I'm trying to ask a series of questions with validation in python. example: What is your...

I'm trying to ask a series of questions with validation in python.

example:

What is your name? (if valid name then continue to question 2)

What is your email? (if not valid then ask this question again, if valid then next question)

How old are you? (again, if invalid then ask again, if valid then next.

import re

def get_new_artwork():

    name_regex = "^(?=.{2,40}$)[a-zA-Z]+(?:[-'\s][a-zA-Z]+)*$"

    email_regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'

    while True:

        name = input('Enter your name: ').title().strip()

        if re.search(name_regex, name) is None:

            print('Invalid name. ')

        else:

            email = input('Enter your email: ')

            if re.search(email_regex, email) is None:

                print('Invalid email. ')

            else:

                age = int(input('How old are you? '))

                if age >=17:

                    print('Too young. ')

                else:                  

                    print('user added. ')

                    break

    return (name, email, age)     

get_new_artwork()

In: Computer Science

Assignment Requirements Write a python application that consists of two .py files. One file is a...

Assignment Requirements

Write a python application that consists of two .py files. One file is a module that contains functions used by the main program. NOTE: Please name your module file: asgn4_module.py

The first function that is defined in the module is named is_field_blank and it receives a string and checks to see whether or not it is blank. If so, it returns True, if not it return false.

The second function that is defined in the module is named is_field_a_number and it receives a string and checks to see whether or not it is a number. If so, it returns True, if not it return false.

The other .py file should properly call a main function that does the following...

1. Prompts the user to enter their first name.

Call the is_field_blank function to see if nothing was entered.
If nothing was entered it displays the following message...

"First Name must be Entered"

...and re-prompts the user to enter the first name. It does this repeatedly until the user enters a first name.


2. Prompts the user to enter their last name.

Call the is_field_blank function to see if nothing was entered.
If nothing was entered it displays the following message...

"Last Name must be Entered"

...and re-prompts the user to enter the last name. It does this repeatedly until the user enters a last name.

3. Prompts the user to enter their age.

Call the is_field_blank function to see if nothing was entered. If nothing was entered it displays the following message...

"Age must be Entered"

...and re-prompts the user to enter their age. It does this repeatedly until the user enters a age.

Once the user has entered a non-blank age call the is_field_a_number function to see if the age entered is a number. If not, display the following message...

"Age must be a Number"


...and re-prompt the user to enter their age. It does this repeatedly until the user enters a numeric age.


4. If the user's age is over 40 display a message in the following format:

Well, (first name) (last name) it looks like you are over the hill


Otherwise display a message in the following format:

It looks like you have many programming years ahead of you (first name) (last name)


5. Follow the format of the "Sample Program" below with the first and last lines appearing as shown. Also, be sure to use line skipping and spacing the way I show below.

Module Documentation Requirement

You MUST add Python Module Documentation to the the module .py program file

Running a Sample Program

Below is a example of how your program might run if you used the same answers to the prompts I used below. Your program should run in a similar manner... no matter what names (data) are entered.

NOTE: The data I entered appear in maroon bold


Sample Run...


Assignment 4


What is your first name?
First Name must be Entered

What is your first name?
First Name must be Entered

What is your first name? Steve

What is your last name?
Last Name must be Entered

What is your last name? Perry

What is your age?
Age must be Entered

What is your age? ff
Age must be a Number

What is your age? ss
Age must be a Number

What is your age? 55

Well, Steve Perry it looks like you are over the hill

END OF ASSIGNMENT 4

In: Computer Science

For this assignment, create a complete UML class diagram of this program. You can use Lucidchart...

For this assignment, create a complete UML class diagram of this program. You can use Lucidchart or another diagramming tool. If you can’t find a diagramming tool, you can hand draw the diagram but make sure it is legible.

Points to remember:

• Include all classes on your diagram. There are nine of them.

• Include all the properties and methods on your diagram.

• Include the access modifiers on the diagram. + for public, - for private, ~ for internal, # for protected

• Include the proper association lines connecting the classes that “know about” each other.

o Associations

o Dependencies

o Inheritance

o Aggregation

o Composition

• Static classes are designated on the diagram with > above the class name, and abstract classes are designated with > above the class name.

-------------------------------------------------------------------

static class GlobalValues
{
private static int maxStudentId = 100;

public static int NextStudentId
{
get
{
maxStudentId += 1;
return maxStudentId;
}
}
}

class College
{
public string Name { get; set; }
public Dictionary<string, Department> Departments { get; } = new Dictionary<string, Department> { };
internal College()
{
Departments.Add("ART", new ArtDept() { Name = "Art Dept" });
Departments.Add("MATH", new MathScienceDept() { Name = "Math /Science Dept" });
}
}

abstract class Department
{
public string Name { get; set; }
public Dictionary<string, Course> CourseList { get; } = new Dictionary<string, Course> { };
protected abstract void FillCourseList();
// Department constructor
public Department()
{
// When a department is instantiated fill its course list.
FillCourseList();
}
}
class ArtDept : Department
{
protected override void FillCourseList()
{
CourseList.Add("ARTS101", new Course(this, "ARTS101") { Name = "Introduction to Art" });
CourseList.Add("ARTS214", new Course(this, "ARTS214") { Name = "Painting 2" });
CourseList.Add("ARTS344", new Course(this, "ARTS344") { Name = "American Art History" });
}
}
class MathScienceDept : Department
{
protected override void FillCourseList()
{
CourseList.Add("MATH111", new Course(this, "MATH111") { Name = "College Algebra" });
CourseList.Add("MATH260", new Course(this, "MATH260") { Name = "Differential Equations" });
CourseList.Add("MATH495", new Course(this, "MATH495") { Name = "Senior Thesis" });
}
}

class Course
{
public readonly Department Department;
public readonly string Number;
private List<Enrollment> Enrollments { get; } = new List<Enrollment> { };
public string Name { get; set; }
internal Course(Department department, string number)
{
Department = department;
Number = number;
}
public void Enroll(Student student)
{
Enrollments.Add(new Enrollment(this, student));
Console.WriteLine($"{ student.Name } has been enrolled in \"{ Name }\".");
}
}

class Student
{
public readonly int Id;
private string name;
public string Name
{
get { return name; }
set
{
name = value;
Console.WriteLine($"{ name } is student ID: { Id }.");
}
}
// New Student constructor with a Student.Id
internal Student(int id)
{
Id = id;
}
// New Student constructor without a Student.Id
internal Student()
{
Id = GlobalValues.NextStudentId;
Console.WriteLine($"A new student has been assigned ID: \"{ Id }\".");
}
}

class Enrollment
{
public readonly Student Student;
public readonly Course Course;
internal Enrollment(Course course, Student student)
{
Student = student;
Course = course;
}
}
class Program
{
static void Main()
{
College MyCollege = new College();
Student Justin = new Student() { Name = "Justin" };
Student Gloria = new Student() { Name = "Gloria" };
MyCollege.Departments["ART"].CourseList["ARTS344"].Enroll(Justin);
MyCollege.Departments["ART"].CourseList["ARTS214"].Enroll(Gloria);
MyCollege.Departments["MATH"].CourseList["MATH111"].Enroll(Justin);
MyCollege.Departments["MATH"].CourseList["MATH260"].Enroll(Gloria);
Console.WriteLine("Press Enter to quit...");
Console.ReadLine();
}
}

In: Computer Science

***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The...

***IN JAVA***

Write a program contained a class Student which has firstName, lastName, mark, grade. The program should allow creation an array of object instances to assign firstName, lastName and mark from input user and perform and assign grade based on mark’s criteria displayed below.

MARKS

INTERVAL

95 - 100

90 - <95

85 - <90

80 - <85

75 - <80

70 - <75

65 - <70

60 - <65

0 - <60

LETTER GRADE

A+

A

B+

B

C+

C

D+

D

F

SAMPLE OF OUTPUT:

Enter section #: 1

How many students: 3

Enter student details:

First Name: John

Last Name: Kendall

Marks      : 96

Enter student details:

First Name: Mary

Last Name: Kendall

Marks      : 76

Enter student details:

First Name: Lucy

Last Name: Kendall

Marks      : 76

Result for Section 1

-------------------------------------------------------------------

FirstName               Last Name         Grade

John                    Kendall           A+

Mary                    Kendall           C+

Lucy                    Kendall           C+

Total students: 3

Average marks: 82.2     Average Grade: B

Highest: 96, by John Kendall

Location: 0

Another batch? (Yes – 1, No - 0) :> 1

Enter section #: 2

How many students: 6

Enter student details:

1)

First Name: John

Last Name: Kendall

Marks      : 96

2)

First Name: Mary

Last Name: Kendall

Marks      : 76

3)

First Name: Lucy

Last Name: Kendall

Marks      : 76

4)

First Name: Martin

Last Name: Kendall

Marks      : 86

5)

First Name: Mary

Last Name: Kendall

Marks      : 76

6)

First Name: Lucy

Last Name: Kendall

Marks      : 98

Result for Section 2

-------------------------------------------------------------------

FirstName               Last Name         Grade

John                    Kendall           A+

Mary                    Kendall           C+

Lucy                    Kendall           C+

Martin                  Kendall           B+

Mary                    Kendall           C+

Lucy                    Kendall           A+

Total students: 6

Average marks : 80.7    Average Grade: B

Highest: 98, by Lucy Kendall

Location: 6

           

Another batch? (Yes – 1, No - 0) :> 0

     

PROBLEM SOLVING TIPS:

Num

Tips

Grade

a)

Use class Student to create another class Students that will be built in the class implementing a Comparator.

/1m

b)

Use for enhanced method to display the grade of student by each batches

/1m

c)

In the main program, create sections of studlist, receive section number and number of students for each section. Use loop control structure to display output as shown in above and to assign input utilizing the studList structure.

/3m

d)

For each section, program will control input firstname, lastname and marks received from user and add into StudList.

/2m

e)

Use appropriate control structure to control input and program execution.

/4m

f)

In main, use Arrays sort() method, to help find the maximum grade achieved by each class and display the name of the student.

/3m

g)

In main, find the average performance (average section, mark and grade) of every batch and include in the output display.

Formula :

Average_mark = total/number of students;

/2m

h)

Use solution for practical provided to extend the program to capable to process more than one sections of students to process.

/ 4m

TOTAL:

/20m

In: Computer Science

Use Excel to calculate the values to fill in the empty boxes. Feel free to add...

Use Excel to calculate the values to fill in the empty boxes. Feel free to add additional tables and calculations as

needed.

Historical Demand Data 2012 to 2016:

The table reproduced below is the demand data for a company (aggregated) for the previous five years.

2012

2013

2014

2015

2016

Q1

11632

15034

16117

15565

16470

Q2

22509

26824

24169

20151

42858

Q3

21646

13314

14505

13392

19278

Q4

11355

10698

11176

10613

13934

Annual Demand

67,142

65,870

65,967

59,721

92,540

Average Quarterly Demand

16,785.50

16,467.50

16,491.75

14,930.25

23,135.00

Forecasting Using Moving Average Methods

Using the historical demand data above, you are to determine the total annual demand forecast for 2016 and 2017 using:

Ø the three-period moving average forecasting method

Ø the three-period weighted moving average method with weights of .6, .3, and .1

Enter your forecast results in the following tables.

2016 Annual Forecast Using a Moving Average

2016 Annual Forecast Using a Weighted Moving Average

63,852.67

62209.7

2017 Annual Forecast Using a Moving Average

2017 Annual Forecast Using a Weighted Moving Average

72742.67

80037

Calculate a Time Series Linear equation using the all of the above demand data:

Using the historical demand data for 2012 through 2016, create a linear equation with the year as the independent variable and the annual volume as the dependent variable.

Enter your linear equation in text from here:   

Calculated 2017 Annual Forecast from Linear Equation:

Forecasting Using an Exponential Smoothing Method and Seasonal Factors:

Using the historical demand data for 2012 through 2016 given on the first page you are to:

Ø Using the exponential smoothing forecasting method with an alpha value of 0.7, forecast the total annual demand for 2017. Start your forecast calculations with the total annual demand for 2012 and a starting forecast for 2012 that is the

Ø Determine the average seasonal factors for each quarter. Remember that you will first need to calculate the total annual demand and then average quarterly demand for each year of data as shown in lecture.

Ø Determine the MAD, CFE, and MAPE errors between the annual forecast values using exponential smoothing for 2013 to 2016 and the actual annual demand data for 2013 to 2016. Enter the values in response to the three questions below.

2012

2013

2014

2015

2016

2017

Actual Annual Demand

67,142

65,870

65,967

59,721

92,540

Forecasted Annual Demand

67,142

67142

66251.6

66052.38

61620.414

Forecast Error

-1,272

-285

-6,331

30,920

Values

Seasonal Factor for each Quarter

2017 Quarterly Forecast

Quarter 1

0.89

Quarter 2

1.63

Quarter 3

0.98

Quarter 4

0.69

Totals

4.19

What is the MAD value for the exponential smoothing forecast? Answer =

What is the CFE value for the exponential smoothing forecast? Answer =

What is the MAPE value for the exponential smoothing forecast? Answer =

Forecasting using trend with regression:

Calculate forecasts for 2017, 2016 and 2015 using a linear regression of the previous three actual demand values.

(Hint: You will need to calculate three different linear equations.)

2012

2013

2014

2015

2016

2017

Actual Annual Demand

67,142

65,870

65,967

59,721

92,540

slope

-587.5

Forecasted Annual Demand

67,142

67,142

66,252

66,052

61,620

intercept

Forecast Error

-6,331

30,920

What is the MAD value for the trend with regression forecast? Answer =

What is the CFE value for the trend with regression forecast? Answer =

What is the MAPE value for the trend with regression forecast? Answer =

In: Operations Management

Morton Forms Morton Forms is a Canadian controlled private corporation owned by Viola Morton. For the...

Morton Forms
Morton Forms is a Canadian controlled private corporation owned by Viola Morton. For the
taxation year ended December 31, 2016, Ms. Morton's daughter, Linda, who works in the
business, has calculated a Net Income for Morton Forms of $576,183. In calculating this figure,
Linda used generally accepted accounting principles.
Linda has produced the following Income Statement for the year ended December 31, 2016:
Morton Forms Inc.
Income Statement Year ending December 31, 2016
Sales $ 7,578,903
Cost of Goods Sold 5,468,752
Gross Profit 2,110,151
Expenses
General and Admin $ 852,000
Amortization Expense 550,000
Interest 8,500 1,410,500
Operating Income    699,651
Other Income:
Loss on Disposal of Intangible Assets (17,000)
Interest Income 110,532
Income before income taxes 793,183
Income Taxes
Current 182,000
Future 35,000 217,000
Net Income $ 576,183
During your review of Linda’s work and last year’s tax return for the corporation, you have made
the following notes:
1. In the accounting records, the Allowance for Doubtful Accounts was $25,000 at
December 31, 2016, and $20,000 at December 31, 2105. During 2016, the company
had actual write-offs of $11,750. As a result, the accounting Bad Debt Expense was
$16,750. This amount is included in General and Admin expenses on the Income
statement.
2. A review of the listing of receivables (for tax purposes), indicates that the actual items
that may be uncollectible total $15,000 at December 31, 2106. In 2015, the company
deducted a reserve for bad debits of $13,000 for tax purposes.
3. General and Admin Expenses include:
a) Donations to registered charities 27,000
b) Accrued Bonuses – Accrued Sept 1, 2016. Paid June 15, 2017 78,000
Meals and entertainment costs:
c) $1,000 per month for premium membership at golf club for Viola 12,000
d) $200 per month for membership at golf club for salespeople 2,400
e) Meals while entertaining clients 32,000
f) Food costs for Viola’s personal chef for her meals at home 5,000
g) Annual summer BBQ for all staff 6,000
h) Sponsorship of local baseball team where company name is
prominently displayed on front of jersey 15,000
i) Advertising in a US trade magazine directed at US clients 100,000
j) New software purchased October 1, 2016. ($13,000 for applications
and $25,000 for systems) 38,000
k) Accounting and legal fees for amended to the articles of
incorporation 6,000
l) Costs to attend annual convention of finger knitters in Thailand.
While at the convention, Viola was sure to hand out business cards
and talk to other attendees about her business with the intention of
claiming the convention as a business expense. 17,000
4. Interest expense consists of the following:
a) Interest expense - operations 5,000
b) Penalty and interest for late and insufficient instalment payments 2,000
c) Interest on late payment of municipal property taxes 1,500


5. Travel costs (included in general and admin expenses) include both air travel and travel
reimbursement to employees for business travel. The company policy is to reimburse
employees $0.58 per kilometer for the business use of their automobiles. During the
year, seven employees each drove 4,000 on employment related activities and one
employee drove 7,500 kilometers. None of the kilometer based allowances are required
to be included in the income of the employees.
6. Maximum CCA has always been taken on all assets. The undepreciated capital cost
balances at January 1, 2016 were as follows:
Class 1 (4%) $650,000
Class 8 95,000
Class 10.1 17,850
Class 14 68,000
Class 291 135,000
Class 44 65,000


1In 2012, used manufacturing and processing equipment was purchased for $4,750,000
from another clothing manufacturer who had gone bankrupt. CCA on this equipment
was fully claimed in 2013, 2014 and 2015. Last year, additional manufacturing and
processing equipment was purchased for $180,000.
7. There was a loss on disposal of a limited life license to produce copyrighted materials for
a major distributor. This license originally cost the company $95,000 , and it was sold for
$63,000 in 2016. The book value of the license at the time of sale was $80,000. When
the license was sold, it was the only asset in its CCA class. The loss was claimed as a
loss on disposal of intangible assets on the Income Statement.


8. The cumulative eligible capital balance at January 1, 2016 was $18,098. Three-quarters
of the $30,000 cost of incorporating the business was put in the CEC account in 2012.
No other items were included in this account prior to the current year.


9. Purchases and sales of equipment and other capital assets made during 2016 were as
follows. (Note: any items discussed in other sections are included in this list as well)
a. The company purchased land and constructed a new building on it during the year.
The building was used 95% for manufacturing and processing. The cost of the land
was $350,000, and the building cost $475,000 to construct.
b. The company purchased a new set of furniture for the reception area for $1,200.
c. Some outdated desks used by the finance department with a cost of $5,000 were
sold for proceeds of $3,500.
d. Landscaping of grounds around the new building cost $35,000. This amount was
capitalized for accounting purposes.
e. A company car for use by the president of the company was purchased for $90,000.
This car replaced the only other existing company car, which was purchased in 2013
for $95,000. The old car was sold for $60,000.
f. A fence around the new building cost $52,000.
g. New software was purchased: $13,000 for Applications and $25,000 for Systems.


10. The company sold some shares that had been purchased several years ago. The
capital gain on these shares was $152,708. Linda didn’t know how to account for this,
so she credited the entire amount to retained earnings.
Required:
Determine Morton Forms’ minimum Net Income for Tax Purposes for the year ending December
31, 2106. Ignore GST/HST/PST implications. Using the supplied formatted Excel spreadsheet,
indicate your rationale for the treatment of all information given.

In: Finance

It is Friday night and Dr. J's classroom is full of eager young students. Yes, it's...

  1. It is Friday night and Dr. J's classroom is full of eager young students. Yes, it's the weekly meeting of the Wizards of Oz, a club for bright preteens interested in science. This particular night is even more special because new members will be officially received into the club. Dr. J had been attracted to the group over a year ago and, after rubbing shoulders with the youngsters, his interest was sparked. His attitude grew more positive over the following months when he saw the tremendous potential associated with their capacity to learn. Being charged with the responsibility of this induction ceremony, Dr. J has decided to use electrostatics as the theme of the evening. Each student is given an experiment to run in order to demonstrate the skills necessary for membership. Having left his patches of wool at home by mistake, Dr. J instructs everyone to use Tripod as their charge cloth. The fur only flies once as Tripod is rubbed the wrong way. (He takes a negative view of his role.) Perhaps the toughest experiment is the one given to the incoming president. Having been told to weigh the pros and cons of pith balls, he has charged two of them equally. They are 3 cm apart and are repelling each other with a force of 4 x 10-5 N. What is the weight of the excess electrons on one of the balls?
  1. Which is more dangerous, touching a faulty 110-volt light bulb or a Van de Graaff generator charged to 100,000 volts? Why? Give a detailed elaborate answer.
  1. Calculate the size of the force that would be experienced by a 3.0 µC charge placed into a uniform electric field of strength 1.0 x 105 N/C.
  1. A – 5.0 mC charge travels due south under the influence of a 10 N force when placed into a uniform electric field. What force would a 10 mC charge experience if placed in the same field and in which direction would it move?
  1. What is the magnitude of a point charge that would create an electric field of 1.00 N/C at points 1.00 m away?
  1. Consider a fixed point charge of +2.00 μC. What is the magnitude and direction of the electric field at a point P, a distance of 0.100 m away?
  1. An electric field has an electric field strength 6000. N/C at a distance of 1.5 m. What is the strength of the field at a distance of 6.0 m?
  1. 24. An alpha (α) particle is positioned in an electric field such that the gravitational force acting on it is equal to the electrostatic force.

             (qα = 3.2 x 10–19 C and mα = 6.64 x 10–27 kg)

a) What is the direction of the electric field at this point?

b) What is strength of the electric field?

c) If the field is located 0.25 m away, what is the magnitude of the charge?

  1. Determine the potential at a point 0.50 m from a 20. µC point charge.
  1. An electric field is parallel to the x-axis. What is the magnitude and direction of the electric field if the potential difference between x = 1.0 m and x = 2.5 m is found to be +900 V?
  1. A charged droplet of mass 5.88 x 1010 kg is hovering motionless between two parallel plates. The parallel plates create have a potential difference of 24000 V and are 2.00 mm apart. What is the charge on the particle?

In: Physics