Starting from:

$25

CSE101 - Introduction to Programming 3 - Solved

 PROBLEMS
 Q1.

 Remembertransformationsmodi ications.the onprobleman n-pointTransformations3D shape. This!! fromproblemAssignmentis an extension2, whereof thatweproblemwere withperformingcertain

  Firstly,code so that there are at least these 3 functions -1.2.3. ifscaletroransyoutate(ldidn’tatex(x, y, (,y xz, ,,z  yscreate, ,xaxis z, ,s tyx,,  ,ps differenttyzh)i, )twhich returns scaled x’,zwhich returns rotated x’,) which returns translatedfunctions for differenty’ and z’ according to sx, sy and sz.y’ and z’ according to axis and phi.x’, y’ and z’ according to tx, ty and tz.transformations, you need to change your

 YouA and B.also have to create a function matmul(A, B) which returns the matrix multiplication of matrices

    Aftercorrectness of the code. In1.thesetusingit returns True, and False otherwise.esestt__modi icationsscalemasztheusingtmu(max,l(ytAthe,mu,z,Blsscale,(xareAQt,rue,s1Bytdone,,es()_sxCfunctionzt,.),ypt,ywhichruezyourthere will be, s_xx,,andtaskstcalculatesyrue, sztests_yis),functiontotruea total of 4 functions -createthethe_z)returnedwhichmatrixanda A3tests_2scales0multiplicationmatrix21thexxxx,returned_y,C1_zwithtinestaccordance.ptrue_C.ofyx’,whichmatricesy’, z’IfwithwilltheywithAtesttrue_x,match,andsx,thesyB

2.       t

3.           twithtrue_y, true_z respectively. If they match, it returns True, and False otherwise.with true_x, true_y, true_z respectively. If they match, it returns True, and False otherwise.andtandesestt__phirottx,ranstatetyusinglate(andx,(yxthe,tz,z,yaxis,usingroz,tatet,xp,hthe(tyix,,,tyruett,zrans,z,t_ruexaxisl,atetrue_,x(p,x_yht,rueiy,),tfunctionruez_y, t,x_tz,rue)tywhich, _tandzz)) whichfunctiontestsrotatesthetranslatesx,andreturnedy, ztestsin accordancex,thex’,y,y’,returnedz inz’ withaccordancewithtrue_x,x’, axisy’, z’

4.

true_y, true_z respectively. If they match, it returns True, and False otherwise.

These matching are expected to be done only using assertions.

YouThisworks.willproblembe makingwill helpmultipleyou intestunderstandingcases for allhowthe functionsa judge onanda competitivewill test yourprogrammingcode’s correctness.website

   QCcwould be used to createll2asse.aninforg aservicescloth andareapparelcrucialCustomer cleaningto ourSplifestyle,eci icservice.details,aestheticsThe and would contain methods/functions for:class wouldand overallbe named,hygiene.LaundYourryStaskerviceis to. Thisdesignclassa

→ __init__(): The parameters passed to this function, during the object instantiation would be:

                                                        Parameter                                                          Appropriate Type/ Values

                     Name of customer                                                          String

                      Contact of customer                                                      Numeric [integer]

                     Email                                                                                    Alphanumeric [string]

                      Type of cloth                                                                    “Cotton”, “Silk”, “Woolen” or “Polyester”

                     Branded                                                                              A boolean

                     Season                                                                                  “Summer” or “Winter” [string]

 variableincremented value must be assigned as theInsideand s__init__(),hould beyouincrewillmentedbe assigningautomaticaid of thean llidnew customer.y whento a newa newcustomer.customerThisisidcreated,would beandglobalthe

 → customer1.2.3.4.5. Their nameTheir contact no.Their emailType of cloth they depositedWhether the cloth is branded or notDetails print out the season(): This will print out the details of a customer in the order:

##No need to

   → calcu1.2.3.  lType of cloth: Cotton → 50 Rupees, Silk → 30 Rs., Woolen → 90 Rs., Polyester → 20 Rs.charge from step 2.Branded: if True,Season:ateChargife()it :isThis will calculate the charge“Winter”1.5 times the charge from step 1.charge is halved fromand return,stepOtherwise the charge is unchanged2. based upon the following factors:Otherwise the charge is 2 times the →itself.further print the total charge and the expected day of return.ina1.2. Furthermore,lDIf total charge is greater than 200,Otherwise, it will print out “To be returned in 7 days”etails():             ThisbasedfunctionuponwillthecallchargecustomerDetails() it will print out “To be returned in 4 days”returned by theandcalculateCharge(),calculateCharge()thisfunctionsfunctionwithinwill

   After creation of the class, you need to able to create multiple objects of typeThecalling indDetails() method from the object created.Caveat:parametersfor the inputto beforpassedbrandfor, youthe initializationcan take 0 orwould1 frombethetakenuser.fromIt canthebeuser.LaundpassedFinallyrySFervicealseyouor.willTruebe, therewise during instantiation.

 

Anothergivenresult as:numberinstantiationof objectsof aornewtheyobjectcan restrictin the samethe numberrunningofcodeobjects(studentfor atleastare free4) wouldto iterategiveforthea

 

The output can deviate in formatting and sequence of statements. This one is for reference only.

  QBandmaintainrate of interests to the users, for now.an[1]blueprint. kalloftheIIIT-Dsomestaffsdesign/prototypeisandemergencybeacannewlyrobustaccountabilityopenopenedandfundsa banktrustworthy,hasforbankofaccounttotheDr.thatbeuserformulatedPankajcaterstheunderinprofessorscaseJalotetotheirthetheforname.needsandneedtheneedDr.bank.arises.TheofsomeonetheRaghavamainThisinstitute.TherepurposewhotaskMutharaju.is nocouldhasThesystemofcomefaculty,bethisreliedAstounderbankstudentsbankingprovideupon,istheto responsibilityAservicesto build the prototype. Can they rely upon you?need to

  Yourmessage,deposited into the bank. Then a menu driven approach has now to be utilized for these 4 tasks:1.taskAsking user to deposit a sumAsking user to withdraw a sumAsking the user if they want to see their bank statement, i.e, their past transaction historyIf the user still wish to continue.andis tothencreateasksathemenuusersdriventointoprovidefromprogram.their accounttheir accounttheirFirstusernameof all, ,thepasswordcode starts, and initiawith lsomeamounwelcomet to be ●          bankStatement()

 1Thisusername,instantiation,→ named__method,iniuser.t__()‘password,u:This.theistxt’the,usualwillwhereinitialbeconstructor,currentauamountuniqueis thebalance.ileusernameprovidedacceptscreatedRemember,4byitself.parametersfortheeveryuserThisthatnewinileduringtheuser.thecontainsmenuobjectYoucurrentdrivencantheinstantiation.assumebalance,transactioncode.thatItjustalsoThesenohistorytwoaftercreatesareusersofthetheaa ilespeci ichave the same name.

 2ThisFalseinstantiation.→ aumethoddependingthenticatewillThis()uponaskmethodthewhetheruseris necessarytheto inputprovidedas“ providemultiplepasswordtheirauthenticationsmatchessecret password”.witharetherequiredpasswordIt wouldduringgiven,returnaduringsession.TruetheorIt would be called everytime a user wants to deposit, withdraw or view his bank statement.

3

      auThisattt→hempedennottmethodpictstsosia!!texceedwhilee”. This AssertionError must be handled usingt(())willtoentering3.verifyIfacceptit does,thea password.theuser.an AssertionErroramountYou needYoutoaddinwilltoopened,beconsiderbewouldgdeposited,theusingamountandbeoneexasseraisedceacaveat!ptexttion asrtto, withit.wouldtothehThereandensuretheparameter.linbemessagewouldg.appendedthe numberbeIt“Tatoowilltomostmantheofbeattempts2yile.wroncallingwronThegg

does

The current balance would be updated, byaThettemp

  Ttext would be of the form:imestampuser speci ic The amounile ‘ut. txtof ’Rwouldupees 1be00.0 againhas been added Current balance → 600.0

 For the timestamp you can use the datetime module directly, whose working is as follows:

Finally you will be closing the ile to ensure no error or glitch persists.

       4Thisalsowould be at most 3, and you would be using → wibemethodthdcallingrawwill()authacceptenticatethe()amountto verifytothebe assewithdrawnuser.rtSimilarion to ensure the same.ortodebited,deposit()as, thenumberparameter.of attemptsAgainallowedit will Thetowithdrawaland then the function would simply return.irstcurrentensurewouldbalancethatnotwouldthebeamountpossiblebe updated,towithbebyawithdrawnmessagesubtractin“Lgisowthelessbamountalancethan!!ftheromCannocurrentit.tAgainbe debalance,abitedcaveat!!at totherwisehYouis timeneed!”

Ifbe appended to it, of the form:the current balance is suf icient, then user speci ic ‘u.txt’ ile would be re-opened and a text would

   Timestamp The amount of Rupees 100.0 has been debited Current balance → 600.0 Finally, the user speci ic ile will be closed for the aforementioned rationale.

  5Thisensure the number of attempts to 3, similar to the steps followed in the previous two methods.Again → bmethodanthekStuseratedoesmenspeci ictnot() acceptile ‘uany.txtparameter.’ will be openedIt also callsin reauadthemode.nticateIt()willforprintveri icationout theandtransactionassert to history line by line.

Forchoice.this question, students’ can implement password validation and email address, as per their One sample run for the said implementation has been attached below:

 

 Also the text ile has been generated :

 

.

  Given a list of people objects, create a functionQ4 sort_attribute() that sorts the list by an attribute

name. The attribute to sort by will be given as a string, one among “firstname”, “lastname”, “age”.

You need to create a class called Person. The class Person has 2 methods inside it. These are as follows:

●     __init__()

This method, the usual constructor, accepts 3 parameters during object instantiation

                        ○    firstname (string)

                        ○    lastname (string)

                        ○    age (int)

●      objecThisorder irstname, lastname and age.tmethod_info() will print all 3 parameters of an instance of a class space separated, in the

For k queries that supply a string among “firstname”, “lastname” or “age”, sort the information for ‘n’ users for that particular attribute and return the person ids in ascending order for that sort of attribute. Print the menu as shown below in sample testcase and use that everytime

Input format:

The first line takes input ‘n’ for n information lines and ‘k’ for k queries

Each of the ‘n’ lines takes 3 space separated inputs: Firstname, Lastname and Age (integer) Each of the next ‘k’ lines takes string inputs that could be “firstname”, “lastname” or “age”

Output Format:

  You can also implement __repr__() function in place of object_info().object_info() function of class Person. Each of the k lines consists of a line separated output of

Sample Menu (white), Input (italics) and Output (bold):

Welcome to the Application!

Specify number of people to be enrolled: 3

Enter Firstname for Person 1: Michael

Enter Lastname for Person 1: Smith

Enter Age for Person 1: 40

Enter Firstname for Person 2: Alice

Enter Lastname for Person 2: Waters

Enter Age for Person 2: 21

Enter Firstname for Person 3: Zoey

Enter Lastname for Person 3: Jones

Enter Age for Person 3: 29

Specify number of Queries: 3 Query 1: firstname Order:

Alice Waters 21

Michael Smith 40

Zoey Jones 29

Query 2: lastname Order:

Zoey Jones 29

Michael Smith 40

Alice Waters 21

Query 3: age Order:

Alice Waters 21

Zoey Jones 29

Michael Smith 40

Thanks for using the Application, if you wish to restart, press “Y” else press “N” to exit: N Exits!

Q5.

Placement Season is about to start at IIITD. You have to design an application to simplify the procedure. You have to make two classes - Student and Company.

Functions for the Student Class are described Below:

1.            __init__ : This function takes 3 parameters: Name (String input), cgpa (Float input) and branch (String input) of the student. Possible branches include CSE, CSAM, ECE. You have to initialise another variable isPlaced to False.

2.            isEligible : This function takes 1 parameter: Object of the Company. It checks if the student is eligible for the given company i.e.

- the student has cgpa >= the required cgpa for the Company, - the company is hiring from the student's branch and - the student is unplaced.

If the student is eligible for that company, then print "Student {name} is eligible for

Company {name}". If the student is not eligible, then print "Student {name} is not eligible for Company {name}"

3.            apply : This function takes 1 parameter: Object of the company. It will add the student to the list of students who have applied for that particular Company.

4.            getsPlaced : This will change the status of the student from unplaced to placed.

Functions for the Company Class are described Below:

1.            __init__ : This function takes 4 parameters: Name (String input), requiredcgpa (float input which is the least cgpa required to become eligible), branches (list of branches from which the company will hire) and positionOpen (which is the maximum number of students that the company will hire). You also have to initialise another variable appliedStudents as an empty list and a variable applicationOpen to True.

2.            hireStudents : This function does not take any parameters and will hire top k students from the list of appliedStudents based on their cgpa (k represents the number of positions open). When the company hires a particular student, you have to change the status of that student to placed. Now print the names of the students that the company has hired and the number of positions open for the company. This function in the end will call the function closeApplication.

3.            closeApplication : This function also does not take any parameter and this will close the application of the Company and print the number of students that the company has hired.

After defining these classes, take inputs of atleast 5 students and 2 companies. Now you have to iterate on all the students and check if he or she is eligible for the company. If the student is eligible, then call the apply function for that student. After iteration on all the students, call the function hireStudents for company 1. Now again iterate on all the students and check if they are eligible and then call the function hireStudents for company 2.

NOTE: Remember while taking the input for the cgpa of the student, you need to use exception handling to ensure that the cgpa lies between 0 and 10. If the cgpa lies outside these bounds, throw exception using assertion statement of your choice (ex → “The cgpa is invalid”, or

“Kindly provide correct  and valid cgpa”, etc ).

Sample Run:

 


 
[1] .4.3.

Herepreviously mentioned tasks.comes the detailed implementation that should work behind the scenes to facilitate the

YouThese are as follows:●●●●need__inipttohhdositenticate__rawcreatet()()() ()a class called BankAccount. The     class BankAccount has 5 methods inside it. auwidet

More products