Python Answers

Questions answered by Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Two is Greater Than One

by CodeChum Admin

They say that the one in first place is always greater than the one in the second and third place. Are they always right?


Instructions:

  1. Input three integers in different lines (one each line).
  2. Print out the integers in one line.
  3. If the 1st integer is greater than or equal to both the 2nd integer and the 3rd integer, print "Yes".

Input

Three lines containing an integer on each.

3
2
1

Output

The first line contains all the three inputted integers.

The second line contains a string which is the result.

3·2·1
Yes

Are Integers Created Equally?

by CodeChum Admin

It's time to find out if something is true or false. Let's test your capabilities by creating a program that checks if two integers are equal!


Instructions:

  1. Input two integers in one line.
  2. Print the two integers in one line, separate them with a space.
  3. Print a string message on a new line, "Equal" if both integers are equal.

Input

A line containing two integers separated by a space.

5·5

Output

The first line contains the two integers input.

The second line contains a string which is the result.

5·5
Equal

The Richest Person


You are given a N entries denoting incomes of people.Same person can have more than one income entry.Write a Program to print person's name and index of the first income entry of the person with highest total income.In case of tie in total income, choose the lexicographically smallest name.


Note:

Name will contain only alphabets and spaces.

Names are case insensitive (i,e Ravi and ravi are same).

Ignore spaces in the name while comparing (i,e Ravi Kishore and RaviKishore are same).


Input

The first line contains an integer N.

Each of next N lines contains the name and income entry of a person.


Sample input1

4

John Cena 1000

John 2000

Jack 4000

Tom 4000


sample output1

Jack 2


]


Swap Letters


Anil is given a sentense S.He tries to make this sentence special.A sentence can be made special by swapping the character with the highest frequency with the character having the lowest frequency in the sentence.Help Anil by transforming the sentence into a special Sentence.

Note:

Consider Upper and lower case letters as different.

If there are multiple letters with the same frequency, choose the lower case letter that comes earliest in dictionary order.

a.If letters like x and B have the same frequency consider x.

b.If letters like x and b have the same frequency consider b.


Input

The first line of input is a string.


sample input1

Python is a programming language.

sample output1

Python is e progremming lenguega.


sample input2

CHECK your blood PRESSURE frequently.

sample output2

CHECK ybur olbbd PRESSURE frequently.


Special Numbers


You only like numbers that start with an odd digit.Anil gives you space-separated integers as input.Your task is left-rotate every number in the list(if required) So that it can be liked by you.


Note:

If there is no odd digit in the number, do not rotate it.

If a number starts with an odd digit, do not rotate it.


Input

The first line of input contains space-separated integers.



sample input1

21 503 256 550 86 979 281

sample output1

12 503 562 550 86 979 128


sample input2

2001 463 6219 669 473 1006 77734 110 20511

sample output2

1200 346 1962 966 734 1006 77734 110 51120


Separate Faulty Items


Jeff Ordered several items from an online shop.After receiving the order, he found that some were faulty.So, he wants to separate the faulty items from the rest.

You are given the prices of the items jeff ordered, where a negative sign indicates a faulty item.Write a program to shift the prices of all the faulty items to the left without changing the relative order of the input.


Input

The first line of input contains space separated integers.


sample input1

11 -12 13 -14 15 16

sample output1

-12 -14 11 13 15 16


sample input2

21 11 -3 -2 9

sample output2

-3 -2 21 11 9


Golden Scores





Write a program to print all the Golden Scores in the list by maintaining their relative order.





Note: The last score is always a golden score.





sample input1



4 5 1 3 2



sample output1



5 3 2







sample input2



9 8 10 12



sample output2



12




5. Create a class BasePlusCommissionEmployee




a. BasePlusCommissionEmployee class is a child class of CommissionEmployee. It should inherit all the attributes of CommissionEmployee class and add its own attribute baseSalary. 




b. Create a method called calculateTotalEarning which should inherit super class method calculateCommission and add baseSalary in it. 


  


c. Create a method called displayData which should display the FirstName, LastName, Age, Address, ContactNumber, EmployeeID, OrganizationName, Position and totalEarning.  


6 Create a complete class diagram of Question-01. Show relationship/inheritance between class. 


(the #292598 is the first part and #292608 is the second part of this question and this is their part so I am requesting that to answers number 6 please also include part 1 and 2 of this question. thank you :)


 4. Create a class SalariedEmployee  


a. SalariedEmployee class is a child class of Employee class. It should inherit all the attributes of 

Employee class and add its own attribute baseSalary. 


b. Create a method called CalculateNetSalary which should deduct 13% Provisional Tax, 1% 

insurance and 3% Fed Tax from baseSalary and display the NetSalary.  


c. Create a method called displayData which should display the FirstName, LastName, Age, 

Address, ContactNumber, EmployeeID, OrganizationName, Position, baseSalary and 

NetSalary.  



1. Create a class Person

a. Initialize a class Person (Constructor method) with FirstName, LastName, Age, Address and Contact Number.


2. Create a class Employee

a. employee is a Person so Employee is a child class of Person class. Employee class 

constructor/__init__ method will contain all the attributes of Person class and Employee 

class own attributes which are EmployeeID, OrganizationName and Position  


3. Create a class CommissionEmployee  15 Marks 

a. CommissionEmployee is a child class of Employee class. It should inherit all the attributes of Employee class and its own attribute which is commissionRate 


b. Create a method called calculateCommission, which should take input of gross sale from the user and based on the commission rate calculate the totalEarning. 


c. Create a method called displayData which should display the FirstName, LastName, Age, Address, ContactNumber, EmployeeID, OrganizationName, Position, commissionRate and  totalEarning.  


LATEST TUTORIALS
APPROVED BY CLIENTS