n a particular board game, there is exactly one row and it comprises N spaces, numbered 0 through N - 1 from left to right. There are also N marbles, numbered 0 through N - 1, initially placed in some arbitrary order. After that, there are two moves available that only can be done one at a time: Switch: Switch the marbles in positions 0 and 1. Rotate: Move the marble in position 0 to position N - 1, and move all other marbles one space to the left (one index lower). The objective is to arrange the marbles in order, with each marble i in position i. 1. Write a class, MarblesBoard, to represent the game above. The class should be initialized with a particular sequence of Marbles. Write an __init__ function that takes a starting sequence of marbles (the number of each marble listed in the positions from 0 to N - 1). (Notice in the sequence all the marbles are different numbers and are sequential numbered but not in order!) Next, write switch() and rotate() methods to simulate the player's moves as described above. Write a method, is_solved(), that returns True if the marbles are in the correct order, False otherwise. Additionally, write __str__ and __repr__ methods to display the current state of the board. Your class should behave like the following example: >>> board

Answers

Answer 1

Answer:

class MarblesBoard(object):

   def __init__(self, seq):

        self.seq = list(seq)

   def switch(self):

       temp = self.seq[0]

       self.seq[0] = self.seq[1]

       self.seq[1] = temp

   def rotate(self):

       temp = self.seq[0]

       for i in range(1, len(self.seq)):

           self.seq[i-1] = self.seq[i]

       self.seq[-1] = temp

   def is_solved(self):

       for i in range(len(self.seq)):

           if i != self.seq[i]:

               return False

       return True

   def __str__(self):  

       return ' '.join(list(map(str,self.seq)))

   def __repr__(self):

       return ' '.join(list(map(str,self.seq)))

class Solver(object):  

   def __init__(self, board):

       self.board = board

   def solve(self):      

       steps = 0

       while not self.board.is_solved():        

           if self.board.seq[0] > self.board.seq[1] and self.board.seq[0] != len(self.board.seq) - 1:

               self.board.switch()

           else:

               self.board.rotate()

           print(self.board)

           steps += 1

       print('Total steps:', steps)

Explanation:

The Python class MarblesBoard creates an object of the board game used in the Solver class object instance and it holds data or attributes of the player piece movement and the magic methods (__str__ and __repr__). The Solver object gets the switch and rotate movementt of the player and displays the total steps at the end of the game.


Related Questions

Select the correct answer.
David gets a new job as a manager with a multinational company. On the first day, he realizes that his team consists of several members from diverse cultural backgrounds. What strategies might David use to promote an appreciation of diversity in his team?
A.
Promote inclusion, where he can encourage members to contribute in discussions.
B.
Create task groups with members of the same culture working together.
C.
Allow members time to adjust to the primary culture of the organization.
D.
Provide training on the primary culture to minority groups only if there are complaints against them.

Answers

C because it’s the smartest thing to do and let the other people get used to each other

Answer:

A.

Explanation:

If we were to go with B, then it would exclude others from different cultures, doing what he is trying to.

If we went with C, then they wouldn't get along very well, because no one likes to be forced into a different religion.

If we went with D, he wants an appreciation, so training some people to change religions if there are complaints, is not going to cut it. Therefore, we have A. Which I do not need to explain.

Susan is a hotel receptionist and checking in a block of rooms for a sports team. All seems to go well, and she checks in the full group. Later in her shift, 2 more players arrive needing a room in the block, but all the rooms have been noted as taken. The coordinator for the group confirms the number of rooms has not changed, and thus there must be one room accidentally checked in. Unfortunately, Susan did not note down which rooms she gave keys out to, and the computer did not list which keys were currently active for each room. How did this mistake happen

Answers

Answer:

This mistake is clearly a result of human and design error

Explanation:

Design errors are those errors that cause human beings to make mistakes.

This question says that the computer did not state the keys that were available for each room. This must have given off the impression that all rooms were occupied to Susan.

On her own part, her failure to note the rooms that she gave out their keys is part of why this mistake happened. This is human error from her part.

Write a function called 'game_of_eights()' that accepts a list of numbers as an argument and then returns 'True' if two consecutive eights are found in the list. For example: [2,3,8,8,9] -> True. The main() function will accept a list of numbers separated by commas from the user and send it to the game_of_eights() function. Within the game_of_eights() function, you will provide logic such that: the function returns True if consecutive eights (8) are found in the list; returns False otherwise. the function can handle the edge case where the last element of the list is an 8 without crashing. the function prints out an error message saying 'Error. Please enter only integers.' if the list is found to contain any non-numeric characters. Note that it only prints the error message in such cases, not 'True' or 'False'. Examples: Enter elements of list separated by commas: 2,3,8,8,5 True Enter elements of list separated by commas: 3,4,5,8 False Enter elements of list separated by commas: 2,3,5,8,8,u Error. Please enter only integers.

Answers

Answer:

In Python:

def main():

   n = int(input("List items: "))

   mylist = []

   for i in range(n):

       listitem = input(", ")

       if listitem.isdecimal() == True:

           mylist.append(int(listitem))

       else:

           mylist.append(listitem)

   print(game_of_eights(mylist))

def game_of_eights(mylist):

   retVal = "False"

   intOnly = True

   for i in range(len(mylist)):

       if isinstance(mylist[i],int) == False:

           intOnly=False

           retVal = "Please, enter only integers"

       if(intOnly == True):

           for i in range(len(mylist)-1):

               if mylist[i] == 8 and mylist[i+1]==8:

                   retVal = "True"

                   break

   return retVal

if __name__ == "__main__":

   main()

Explanation:

The main begins here

def main():

This gets the number of list items from the user

   n = int(input("List items: "))

This declares an empty list

   mylist = []

This iterates through the number of list items

   for i in range(n):

This gets input for each list item, separated by comma

       listitem = input(", ")

Checks for string and integer input before inserting item into the list

       if listitem.isdecimal() == True:

           mylist.append(int(listitem))

       else:

           mylist.append(listitem)

This calls the game_of_eights function

   print(game_of_eights(mylist))

The game_of_eights function begins here

def game_of_eights(mylist):

This initializes the return value to false

   retVal = "False"

This initializes a boolean variable to true

   intOnly = True

This following iteration checks if the list contains integers only

   for i in range(len(mylist)):

If no, the boolean variable is set to false and the return value is set to "integer only"

       if isinstance(mylist[i],int) == False:

           intOnly=False

           retVal = "Please, enter only integers"

This is executed if the integer contains only integers

       if(intOnly == True):

Iterate through the list

           for i in range(len(mylist)-1):

If consecutive 8's is found, update the return variable to True

               if mylist[i] == 8 and mylist[i+1]==8:

                   retVal = "True"

                   break

This returns either True, False or Integer only

   return retVal

This calls the main method

if __name__ == "__main__":

   main()

Write a program that takes a list of integers as input. The input begins with an integer indicating the number of integers that follow. You can safely assume that the number of integers entered is always less than or equal to 10. The program then determines whether these integers are sorted in the ascending order (i.e., from the smallest to the largest). If these integers are sorted in the ascending order, the program will output Sorted; otherwise, it will output Unsorted

Answers

Answer:

is_sorted = True

sequence = input("")

data = sequence.split()

count = int(data[0])

for i in range(1, count):

   if int(data[i]) >= int(data[i+1]):

       is_sorted = False

       break

if is_sorted:

   print("Sorted")

else:

   print("Unsorted")

Explanation:

*The code is in Python.

Initialize a variable named is_sorted as True. This variable will be used as a flag if the values are not sorted

Ask the user to enter the input (Since it is not stated, I assumed the values will be entered in one line each having a space between)

Split the input using split method

Since the first indicates the number of integers, set it as count (Note that I converted the value to an int)

Create a for loop. Inside the loop, check if the current value is greater than or equal to the next value, update the is_sorted as False because this implies the values are not sorted (Note that again, I converted the values to an int). Also, stop the loop using break

When the loop is done, check the is_sorted. If it is True, print "Sorted". Otherwise, print "Unsorted"

The online underground is used _____. Select 3 options. by law-abiding citizens only on Black Friday for networking by criminal organizations by world governments to share military secrets by cybercriminals to purchase malicious software by cybercriminals to sell ransom services

Answers

Answer:

The online underground is used :- 1] by cybercriminals to purchase malicious software.

2] by cybercriminals to sell ransom services.

3] by criminal organizations.

I hope it's correct.

The online underground is used by criminal organizations, by cybercriminals to purchase malicious software, and by cyber criminals to sell ransom services. Hence, options B, D, and E are correct.

What is online underground?

The online underground, also known as the dark web or the darknet, refers to a portion of the internet that is intentionally hidden and can only be accessed using specialized software, such as the Tor browser. The online underground is typically used for illegal activities, such as drug trafficking, weapons sales, identity theft, and other criminal activities.

The online underground is used by the following:

Criminal organizationsCybercriminals to purchase malicious softwareCybercriminals to sell ransom services

Therefore, options B, D, and E are correct.

Learn more about online underground, here:

https://brainly.com/question/14447126

#SPJ2

Which of these are examples of how forms are
used? Check all of the boxes that apply.
to input patient information at a doctor's office
O to store thousands of records
to check out books from a library
to choose snacks to buy from a vending
machine

Answers

Answer:to input patient information at a doctors office

To check out books from a library

To choose snacks to buy from a vending machine

Explanation:

A. To input patient information at a doctor's office, C. To check out books from a library, and D. To choose snacks to buy from a vending machine are examples of how forms are used. Therefore option A, C and D is correct.

Forms are used in various settings and scenarios to collect and manage data efficiently.

In option A, forms are utilized at doctor's offices to input and record patient information, streamlining the registration and medical history process.

In option C, library check-out forms help manage book borrowing, recording details like due dates and borrower information. Option D showcases how vending machines use forms to present snack options, allowing users to make selections conveniently.

All these examples demonstrate the versatility of forms as tools for data collection, organization, and user interaction, contributing to smoother operations and improved user experiences in different domains.

Therefore options A To input patient information at a doctor's office, C To check out books from a library, and D To choose snacks to buy from a vending machine are correct.

Know more about vending machines:

https://brainly.com/question/31381219

#SPJ5

How many different values can a bit have?
16
2
4.
8

Answers

Answer:

A bit can only have 2 values

Let X and Y be two decision problems. Suppose we know that X reduces to Yin polynomial time. Which of the following statements are true?Explain
a. If Y is NP-complete then so is X.
b. If X is NP-complete then so is Y.
c. If Y is NP-complete and Xis in NP then X is NP-complete.
d. If X is NP-complete and Y is in NP then Y is NP-complete.
e. If X is in P, then Y is in P.
f. If Y is in P, then X is in P.
g. X and Y can't both be in NP

Answers

Answer:

d. If X is NP - complete and Y is in NP then Y is NP - complete.

This can be inferred

Explanation:

The statement d can be inferred, rest of the statements cannot be inferred. The X is in NP complete and it reduces to Y. Y is in NP and then it is NP complete. The Y is not in NP complete as it cannot reduce to X. The statement d is inferred.

In a scenario where Nancy and Matthew are using public key encryption, which keys will Nancy have the ability to see in her public keyring (--list-keys)?

Answers

Answer:

Private key

Explanation:

From the question, we understand that the encryption type is a public encryption.

For better analysis, I will create the following scenario.

Encryption keys are stored in an encrypted form in a PGP (i.e. Pretty Good Privacy). This PGP homes the public and the private keys.

However, for Nancy to access the public keyring, she needs the private keys.

If by chance she lost/forgot the private keys, she will not be able to decrypt any information she receives.

Hence, the solution to this question is: private key

Post a Python program that accepts at least two values as input, performs some computation and displays at least one value as the result. The computation must involve calling one of the predefined functions in the math library. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least one test case.

Answers

Answer:

In Python:

#The program calculates and prints the remainder when num1 is divided by num2 using the fmod function

import math

num1 = int(input("Input 1: "))

num2 = int(input("Input 2: "))

print(math.fmod(num1, num2))

Explanation:

This program begins with a comment which describes the program function

#The program calculates and prints the remainder when num1 is divided by num2 using the fmod function

This imports the math module

import math

The next lines get input for num1 and num2

num1 = int(input("Input 1: "))

num2 = int(input("Input 2: "))

This calculates and prints the remainder when num1 is divided by num2

print(math.fmod(num1, num2))

All of the following statements about cookies are true except: Question 16 options: cookies can be used to create cross-site profiles of users. the data typically stored in cookies includes a unique ID and e-mail address. cookies make shopping carts possible by allowing a site to keep track of a user's actions. the more cookies are deleted, the less accurate ad server metrics become

Answers

Answer:

the data typically stored in cookies includes a unique ID and e-mail address.

Explanation:

A cookie can be defined as a text file created by a website and it comprises of small amounts of data such as username and password.

This ultimately implies that, this small piece of data known as cookies is a unique identification number saved by a web browser and as such are typically used to identify a host computer.

All of the following statements about cookies are true;

I. Cookies can be used to create cross-site profiles of users.

II. Cookies make shopping carts possible by allowing a site to keep track of a user's actions.

III. The more cookies are deleted, the less accurate ad server metrics become.

Uma wants to create a cycle to describe the seasons and explain how they blend into each other. Which SmartArt diagram would work best for this?

Answers

Answer: SmartArt offers different ways of visually presenting information, using shapes arranged in different formations.

Explanation:SmartArt offers different ways of visually presenting information, using shapes arranged in different formations. The SmartArt feature also allows you to preview different SmartArt formations, making it very easy to change shapes and formations.

Question #3..plz help

Answers

What is question number 3

1. Create a Java program.
2. The class name for the program should be 'RandomDistributionCheck'.
3. In the main method you should perform the following:
a. You should generate 10,000,000 random numbers between 0 - 19.
b. You should use an array to hold the number of times each random number is generated.
c. When you are done, generating random numbers, you should output the random number, the number of times it occurred, and the percentage of all occurrences. The output should be displayed using one line for each random number.
d. Use named constants for the number of iterations (10,000,000) and a second named constant for the number of unique random numbers to be generated (20).

Answers

Answer:

In Java:

import java.util.*;

public class RandomDistributionCheck{

   public static void main(String[] args) {

       final int iter = 10000000;

       final int unique = 20;

       Random rd = new Random();

       int [] intArray = new int[20];

       for(int i =0;i<20;i++){    intArray[i]=0;    }

       for(int i =0; i<iter; i++){

           int rdd = rd.nextInt(20);

           intArray[rdd]++;    }

       System.out.println("Number\t\tOccurrence\tPercentage");

       for(int i =0;i<unique;i++){

           System.out.println(i+"\t\t"+intArray[i]+"\t\t"+(intArray[i]/100000)+"%");

       }    } }

Explanation:

This declares the number of iteration as constant

       final int iter = 10000000;

This declares the unique number as constant

       final int unique = 20;

This creates a random object

       Random rd = new Random();

This creates an array of 20 elements

       int [] intArray = new int[20];

This initializes all elements of the array to 0

       for(int i =0;i<20;i++){    intArray[i]=0;    }

This iterates from 1 to iter

       for(int i =0; i<iter; i++){

This generates a random number

           int rdd = rd.nextInt(20);

This increments its number of occurrence

           intArray[rdd]++;    }

This prints the header

       System.out.println("Number\t\tOccurrence\tPercentage");

This iterates through the array

       for(int i =0;i<unique;i++){

This prints the required output

           System.out.println(i+"\t\t"+intArray[i]+"\t\t"+(intArray[i]/100000)+"%");

       }  

Dr. Smith is teaching IT 102 and wants to determine the highest grade earned on her midterm exam. In Dr. Smith's class, there are 28 students. Midterm exam grades fall in the range of 0 to 100, inclusive of these values. Write a small program that will allow Dr. Smith to enter grades for all of her students, determine the highest grade, and output the highest grade.

Answers

Answer:

mysql

Explanation:

try building mysql database

Which operating system user interface does not reside on the computer but rather in the cloud on a web server?

Answers

Efficiency is not a type of user interface

Question 21
What is the minimum sum-of-products expression for the following Kmap?
AB
00
01
11
10
CD
00
1
0
01
0
0
0
O
11
0
0
1
1
10
1
1
1
1

Answers

Answer:

1010010010001010

Explanation:

0100101010010101010

Consider the following statement, which is intended to create an ArrayList named years that can be used to store elements both of type Integer and of type String. /* missing code */ = new ArrayList(); Which of the following can be used to replace /* missing code */ so that the statement compiles without error?

a. ArrayList years
b. ArrayList years()
c. ArrayList years[]
d. ArrayList years
e. ArrayList years

Answers

Answer:

a. ArrayList years

Explanation:

Required

Complete the code segment

The programming question is about Java programming language.

In java, the syntax to declare an ArrayList of no specific datatype is:

ArrayList [List-name] = new ArrayList();

From the question, the name of the ArrayList is years.

So, the syntax when implemented is:

ArrayList years = new ArrayList();

So, the comment /*missing code*/ should be replaced with: ArrayList years

The option that can be used to replace /* missing code */ so that the statement compiles without error is;

A: ArrayList years

This question deals with programming language in Java.

Now, from the question, we are dealing with an ArrayList and In java, the syntax that is used to declare an ArrayList of no specific data type is given as;

ArrayList [Lists name] = new ArrayList();

Now, in the question the list name is given as "years". Thus;

The correct statement to replace /* missing code */ so without errors is;

ArrayList years.

Read more about Java syntax at; https://brainly.com/question/18257856

A realtor is studying housing values in the suburbs of Minneapolis and has given you a dataset with the following attributes: crime rate in the neighborhood, proximity to Mississippi river, number of rooms per dwelling, age of unit, distance to Minneapolis and Saint Paul Downtown, distance to shopping malls. The target variable is the cost of the house (with values high and low). Given this scenario, indicate the choice of classifier for each of the following questions and give a brief explanation.
a) If the realtor wants a model that not only performs well but is also easy to interpret, which one would you choose between SVM, Decision Trees and kNN?
b) If you had to choose between RIPPER and Decision Trees, which one would you prefer for a classification problem where there are missing values in the training and test data?
c) If you had to choose between RIPPER and KNN, which one would you prefer if it is known that there are very few houses that have high cost?

Answers

Answer:

a. decision trees

b. decision trees

c. rippers

Explanation:

a) I will choose Decision trees because these can be better interpreted compared to these other two KNN and SVM. using Decision tress gives us a better explanation than the other 2 models in this question.

b)  In a classification problem with missing values, Decision trees are better off rippers since Rippers avoid the missing values.

c) Ripper are when we know some are high cost houses.

PLEASE HELP How have phones made us spoiled? How have phones made us unhappy?

Answers

phones have made us spoiled because we have everything at our fingertips. we get what we want when we see something online and we want to get it all we do is ask and most of us receive. phone have made us unhappy mentally and physically because we see how other people have it like richer for instance and we want that and we get sad about weird things because of what we see like other peoples body’s how skinny someone is and how fat someone is it makes us sad because we just want to be like them.

does anyone know what functions to write for the rock paper scissors app in code.org (Lesson 4: parameters and return make)?

Answers

Answer:

Explanation:

Based on the example of the app on the website there are two main functions that are needed. The first is the updatecomputer_resultbox function which creates the choice for the computer in the game whether it is rock, paper, or scissors. The second function would be the calculate_winner function which compares your choice with the computers choice and decides on who won. The rest of the needed functions are the event functions to handle the clicks on each one of the games buttons such as play, rock, paper, scissor, and end game/replay.

How many thermal performance control modes are there in Alienware Area 51m to support different user scenarios?

Answers

Answer:

3

Explanation:

The Dell Alienware Personal Computers refers to a range of PC's which are known for their strength, durability and most commonly their graphical performance. Th ecomputwrs are built to handle very high and intensive graphic demanding programs including gaming. The Alienware area 51m is a laptop which has been loaded with the capability and performance of a high graphic demanding desktop computers boasting massive memory size and greater graphic for better game play and high graphic demanding programs.

The laptop features an improved thermal and performance capability to handle the effect of different graphic demanding programs. Therfore, the laptop has 3 different thermal a d performance system modes which altenrtes depending on graphic demands in other to handle intensive demands.

It should be noted that the number of thermal performance mode is 5.

From the complete information, it should be noted that there are five thermal performance control modes are there in Alienware Area 51m to support different user scenarios.

The modes are:

Full speed mode.Performance mode.Balanced mode.Quiet mode.Cool mode.

In conclusion, the correct option is 5

Learn more about modes on:

https://brainly.com/question/25604446

Charging current being returned to the battery is always measured in DC Amps. true or false

Answers

Answer:Charging current being returned to the battery is always measured in DC Amps. Electrical energy will always flow from an area of low potential to an area of high potential. ... One volt is the pressure required to force one amp of current through a circuit that has 1 Ohm of resistance.

Explanation:

Which feature in Access is used to control data entry into database tables to help ensure consistency and reduce errors?

O subroutines
O search
O forms
O queries

Answers

The answer is: Forms

To control data entry into database tables to help ensure consistency and reduce errors will be known as forms in data entry.

What are forms in data entry?

A form is a panel or panel in a database that has many fields or regions for data input.

To control data entry into database tables to help ensure consistency and reduce errors will be forms.

Then the correct option is C.

More about the forms in data entry link is given below.

https://brainly.com/question/10268767

#SPJ2

A service specialist from your company calls you from a customer's site. He is attempting to install an upgrade to the software, but it will not install; instead, it he receives messages stating that he cannot install the program until all non-core services are stopped. You cannot remotely access the machine, but the representative tells you that there are only four processes running, and their PID numbers are 1, 10, 100, and 1000. With no further information available, which command would you recommend the representative run?

Answers

Answer:

kill 1000

Explanation:

Complete the line of code in this program that uses the randint() function?
correctAnswer = randint(1,20)

Answers

Answer:

Following are the code to the given question:

import random as r#import random package

correctAnswer = r.randint(1,20)#defining a variable correctAnswer that hold randint method value

print(correctAnswer)#print correctAnswer variable value

Output:

15

Explanation:

In the above-given python code, a random package is imported as the "r", and in the next step, the "correctAnswer" variable is declared that uses the randit method with two integer parameters that are "1,20" and returns a value that holds a value into its variable, and use the print method to prints its value.

Answer:

from random import *

Explanation:

edge :)

have a wonderful day <3

Select the correct answer.
Which statement is true about informal communication?
A.
Informal communication consists of centralized patterns of communication.
B.
It is any form of communication that does not use a written format.
C.
Physical proximity of people favors the occurrence of informal communication.
D.
It exists only when there is no formal communication channel in the organization.

Answers

hey,i’m pretty sure it’s D:)

Answer:

D.

It exists only when there is no formal communication channel in the organization.

Explanation:

Ask the user to input their grade percentage (e.g. the use will enter 98 if they had an overall grade of 98% in their course) for their Accounting, Marketing, Economics and MIS courses. Assume each course is worth 3 credit hours. Once you have all of their grades output what letter grade they earned for each course (e.g. Your letter grade for {Accounting/Marketing/whichever one you are outputting} is {A/B/C/D/F}). After you have output all of their letter grades, output their overall GPA for the semester using the formula:
Letter Grade Point Value for Grade
A 4.00
B 3.00
C 2.00
D 1.00
F 0.00
Example Student Transcript
Course Credit Hours Grade Grade Points
Biology 5 A 20
Biology Lab 1 B 3
English 5 C 10
Mathematics 5 F 033
16 Total Credits Attempted 33 Total Grade Points
Total Points Earned/Total Credits Attempted = Grade Point Average
33 Points Earned/16 Credits Attempted = 2.06 GPA
For more details on how to calculate your GPA, go to http://academicanswers.waldenu.edu/faq/73219 e
GPA - Convert MIS grade to letter grade using a conditional statement
GPA - Convert Accounting letter grade to points earned (can be done in same conditional as letter grade
GPA - Convert Marketing letter grade to points earned (can be done in same conditional as letter grade)
GPA-Convert Economics letter grade to points earned (can be done in same conditional as letter grade)
GPA-Convert MIS letter grade to points earned (can be done in same conditional as letter grade) GPA - Calculate the GPA
GPA-Output the letter grade for each course
GPA-Output the overall GPA for the semester

Answers

Answer:

In Python

def getpointValue(subject):

   if subject >= 75:        point = 4; grade = 'A'

   elif subject >= 60:        point = 3; grade ='B'

   elif point >= 50:        point = 2; grade = 'C'

   elif point >= 40:        point = 1; grade = 'D'

   else:        point = 0; grade = 'F'

   return point,grade

subjects= ["Accounting","Marketing","Economics","MIS"]

acct = int(input(subjects[0]+": "))

mkt = int(input(subjects[1]+": "))

eco = int(input(subjects[2]+": "))

mis = int(input(subjects[3]+": "))

acctgrade = getpointValue(acct)

print(subjects[0]+" Grade: "+str(acctgrade[1]))

mktgrade = getpointValue(mkt)

print(subjects[1]+" Grade: "+str(mktgrade[1]))

ecograde = getpointValue(eco)

print(subjects[2]+" Grade: "+str(ecograde[1]))

misgrade = getpointValue(mis)

print(subjects[3]+" Grade: "+str(misgrade[1]))

totalpoint = (acctgrade[0] + mktgrade[0] + ecograde[0] + misgrade[0]) * 3

gpa = totalpoint/12

print("GPA: "+str(gpa))

Explanation:

The solution I provided uses a function to return the letter grade and the point of each subject

I've added the explanation as an attachment where I used comment to explain difficult lines

There is a file of a few Sean Connery movies on the internet. Each entry has the following form:
Name of Movie
Release Date
Running Time (maybe)
Several names of some of the stars
A separator line (except after the last movie)
Your assignment is: for each movie,
1. read in the Name, Release Date, the stars
2. Sort the movies by Movie Name alphabetically,
2. Sort the stars alphabetically, by last name
3. Print the Movie Name, Release Date, Running Time (if there) and Print the list of stars (alphabetically, by last name).
Click here to see the Input File
Some Sample Output:
Darby O'Gill and the Little People
1959
RT 93 minutes
Sean Connery
Walter Fitzgerald
Kieron Moore
Janet Munro
Jimmy O'Dea
Albert Sharp
Estelle Winwood

Answers

Answer:

filename = input("Enter file name: ")

movie_container = list()

with open(filename, "r") as movies:

   content = movies.readlines()

   for movie in content:

       holder = movie.split("\t")

       movie_container.append((holder[0], holder[1], holder[2], holder[3]))

movie_container = sorted(movie_container, key= lambda movie: movie[0])

for movie in movie_container:

   movie_stars = movie[3].split(",")

   name_split = [names.split(" ") for names in movie_stars]

   movie_stars.clear()

   name_split = sorted(name_split, key= lambda names: names[1])

   for name in name_split:

       full_name = " ".join(name)

       print( full_name)

       movie_stars.append(full_name)

   movie[3] = movie_stars

print(movie_container)

Explanation:

The python code uses the open function to open and read in the input file from the standard user prompt. The title of the movies and the stars are all sorted alphabetically and display at the output.

Summary
You will write a racing report program using object-oriented programming with three classes:
ReportDriver, RaceReport, and Race. The main method of the program will be in the
class ReportDriver and will include a loop that allows you to enter in more than one race and
have reports written out for all the races you enter. (The user will enter one race then get a report for that race. After that, the user will be asked whether they want to enter in another race and get another report. This repeats until the user says they do not want to enter in any more races.)
Program Description
There are two major tasks in this assignment. Your first major task is to write a program that collects three pieces of user input about a race and provides a summary of facts about the race. Input will be via the keyboard and output (i.e., the summary of facts) will be via the display (a.k.a., console window). The three pieces of user input will be the three individual race times that correspond the first, second, and third top race finishers; your program will prompt the user to enter these in via the keyboard. Note that you cannot assume these times will be in order; putting them in order is one of the first things your program should do. Thus, your program will need to do the following:
1. Prompt the user for three ints or doubles, which represent the times for the three racers.
2. Sort the three scores into ascending order (i.e., least to greatest).
(a) Remember, to swap two variables requires a third, temporary variable.
(b) See the Math class (documented in Savitch Ch. 5; see the index for the exact location
. . . this is good practice for looking things up) for methods that might help you (e.g.,
min and max). Note that these methods produce a return value.
(c) Output the sorted race scores in order.
3. Describe the overlap in times, if any exist. The options will be:
(a) All are tied for first.
(b) Some are tied for first.
(c) None are tied for first.
4. Do step (4) for the second and third place finishes.
5. Output the range of the race scores.
6. Output the average of the race scores.
There are, of course, many different ways of writing this program. However, if you decompose
your tasks into smaller chunks, attacking a larger program becomes more manageable. If you
mentally divided up the tasks before you, you might have decided on the following list of "work
items", "chunks", or "modules":
Data Input: Ask the user for three race scores (in no particular order).
Ordering Data: Order the race scores by first, second, and third place.
Data Analysis and Output:
– Determine how many racers tied for first, second or third place (i.e., how many overlap
times) and output result to console.
– Calculate the range of the race scores (i.e., the absolute value of the slowest minus the
fastest times) and output result to console.
2 – Calculate the average of the race times and output result to console.

Answers

Answer:dddd

Explanation:

//The code is all written in Java and here are the three classes in order ReportDriver, RaceReport, and Race

class ReportDriver {

   

   public static void main(String[] args) {

       boolean continueRace = true;

       Scanner in = new Scanner(System.in);

       ArrayList<ArrayList<Integer>> races = new ArrayList<>();

       while (continueRace == true) {

           System.out.println("Would you like to enter into a race? Y or N");

           char answer = in.next().toLowerCase().charAt(0);

           if (answer == 'y') {

               Race race = new Race();

               races.add(race.Race());

           } else {

               break;

           }

       }

       for (int x = 0; x <= races.size()-1; x++) {

           RaceReport report = new RaceReport();

           report.RaceReport(races.get(x));

           report.printRange();

           report.printAverage();

       }

   }

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package sample;

import java.util.ArrayList;

public class RaceReport {

   int range, average;

   String first, second, third;

   public void RaceReport(ArrayList<Integer> times) {

       if (times.get(2) == times.get(1)) {

           if (times.get(2) == times.get(0)) {

               System.out.println(first = "Times tied for first place are " + times.get(2) + " and " + times.get(1) + " and " + times.get(0));

           } else {

               System.out.println(first = "Times tied for first place are " + times.get(2) + " and " + times.get(1));

               System.out.println(second = "Second place time is " + times.get(0));

           }

       } else if (times.get(1) == times.get(0)) {

           System.out.println(first = "First place time is " + times.get(2));

           System.out.println(second = "Times tied for Second place are " + times.get(1) + " and " + times.get(0));

       } else {

           System.out.println(first = "First place time is " + times.get(2));

           System.out.println(second = "Second place time is " + times.get(1));

           System.out.println( third = "Third place time is " + times.get(0));

       }

       range = Math.abs(times.get(0) - times.get(2));

       average = (times.get(2) + times.get(1) + times.get(0) / 3);

   }

   public void printRange() {

       System.out.println("The range of the race was " + range);

   }

   public void printAverage() {

       System.out.println("The average of the race was " + average);

   }

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package sample;

import java.util.ArrayList;

import java.util.Collections;

import java.util.Scanner;

public class Race {

   Scanner in = new Scanner(System.in);

   ArrayList<Integer> times = new ArrayList<>();

   public ArrayList<Integer> Race() {

       System.out.println("Input time 1:");

       times.add(in.nextInt());

       System.out.println("Input time 2:");

       times.add(in.nextInt());

       System.out.println("Input time 3:");

       times.add(in.nextInt());

       Collections.sort(times);

       return times;

   }

}

Other Questions
Are the ratios 3:6 and 6:3 equivalent? Why or why not? Which is not a type of mass movement Maddox starts hiking from The main entrance trail penny starts Her hike from the same entrance a little while later the equation below represents distance D in yards that each person is from the entrance of the Trail minutes after penis starts hiking from a entrance Maddox: d=40m+200 penny: d=50m which statement is true penny Will be able to catch up Which happened last?A. the U.S. enters the warB. the Zimmerman telegramC. the sinking of the LusitanicD. World War I begins What is your favorite thing to eat? is it healthy or unhealthy ? I'm in need of an answer im not just wasting points for your benefit anymore.. Chris has handed over the screenplay to the sound designer to design the sounds in the movie. He told the sound designer that he has deany Indicated each sound in every scene. How do you think Chris indicated the sound effects in the screenplay? OA by making the word indicating sound boldface OB by capitalizing the word indicating sound OC. by highlighting the word indicating sound OD. by underlining the word indicating sound can someone help me with this please its due tomorrow Powerful organizations linked to political parties are called..A.ProhibitionsB.KickbacksC.Political MachinesD.Isolationists Susan is meeting with some classmates to discuss a class project. What type of social group is this? Divide 2/3 1/4. Write your answer in mixed number. hey say that the children of the ones who could not fly told their children. And now, me, I have told it to you.How does this excerpt show that the story is a folktale?It is passed down through the written word.It is shared through oral tradition.It is passed down through letters.It is shared in a secretive manner. True or False:Meiosis make 4 unique gametes (reproductive cells) sobre que te tema te gustaria escribir Which brand contains the smallest DNA fragments?What term describes the technique that was used to generate the results shown in the figure Help Fast, I will give out a ton of points! Ayala has 806 computer files she wants to put on CDs.If she can fit 19 files on each CD, how many CDs will she need? Enter the correctanswer to complete the statement. 3^x+1=sqrt3 [tex] {3 }^{x + 1} = \sqrt{3} [/tex]Help plz By June of 1940, Hitler had already done which of the following? Check all that apply.O He had invaded Russia.O He had conquered Noway.D He had conquered Great Britain.D He had invaded the NetherlandsO He had pushed Allied forces out of France.O He had forced the United States to join the war. Blood types;A man with type O marries a woman with type AB.Several children were born.1. What is the genotype of the man?2. What is the genotype of the woman?3. True or false? the mother of the man had type AB blood. 4. Could the mother of the woman have type O blood? 5. what fraction of offspring would have type B blood?6. what fraction of the children would have type AB blood?7.Could this couple have a child with type O blood? Why do we not see the colors of the other pigments, such as yellow?