Questions: 5 290

Answers by our 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 & Filtering

Swap Competition




An English competition is being held where players have to play in groups of two. One of the players is given a word, and the second player has to choose a word such that, it is a rearrangement of the letters in the first player's word. They win if the above condition is satisfied. The number of groups is given by T.Write a programthat gives YES if they win and NO in the other case.




Note: All characters in the input will be in lower case.




Input




The first line of the input contains an integer T Each of the next T lines contains two words separated by space.




Output




The output should have the results of each of the T are given in the input.




groups that



All the results are separated by space.



Explanation




Given pairs




noon moon




part trap







Sample Input 1




2




noon moon part trap




Sample Output 1




NO YES




Sample Input 2




2




car rac




lock clock




Sample Output 2




YES, NO





A class called MyPoint, which models a 2D point with x and y coordinates. It contains:



 Two private instance variables x (int) and y (int).


 A constructor (__init__()) that constructs a point with the given x and y coordinates.


 Getter and setter for the instance variables x and y.


 Method setXY() to set both x and y.


 Method getXY() which returns the x and y in a 2-element list.


 A __str__ method that returns a string description of the instance in the format "(x, y)".


Method called distance(self, anotherpoint) that returns the distance from this point to the given MyPoint instance (called another), e.g.,



p1 = MyPoint(3, 4)


p2 = MyPoint(5, 6)


print(p1.distance(p2))



Method called distance_from_origin() method that returns the distance from this point to the origin (0,0), e.g.,



p1 = MyPoint(3, 4)


print(p1.distance_from_origin())

proper fractions

Given two fractional values A/C ,B/D where A,B are numbers and C,D are denominators you asked to add two fractional values, if the sum gives proper fraction as output print the proper fraction if it is improper ,convert it into a mixed fraction and print it if it is a whole number, print it

the 1st line of input contains two space separeted strings A/C, B/D

input:

1/2 1/4

o/p:

3/4

i/p:

1/2 3/4

o/p:

11/4(that means 1(1/4))

i/p:

1/3 2/3

o/p:

1


Dice Score:

two friends are playing a dice game, the game is played with five six-sided dice. scores for each type of throws are mentioned below.

three 1's = 1000 points

three 6's = 600

three 5's = 500

three 4's = 400

three 3's = 300

three 2's = 200

one 1 = 100

one 5 = 50

I/p: 2

1 1 1 1 1

6 6 6 1 5

O/p: 1200

750

I/p: 2

2 1 5 2 2

1 1 1 2 2

O/p: 350

1000


Number of moves:


you are given a nxn square chessboard with one bishop and k number of obstacles placed on it. A bishop can go to different places in a single move. find the total no.of places that are possible for the bishop in a single move. Each square is referenced by a type describing the row, R, and column, C, where the square is located.


explanation: given N=6 K=2


bishop position 5 2


obstacle positions (2 2), (1 5)


the bishop can move in so o/p is 6


I/p:


6 2


5 2


2 2


1 6


O/p:


6


I/p:


6 4


3 3


1 3


3 1


5 1


1 5


O/p: 7


Ash is now an expert in python function topic. So, he decides to teach others what he knows by making a question on it. Problem statement of his question is as follows.

Your task is to write a function outer_layer(num) that returns function inner_layer, where num is a positive integer. Function inner_layer(div) check whether num is divisible by div or not, its return type is bool (True/ False).

num is of type string

div is of type int and belongs to {2, 5, 9, 10}


Functions are Objects - Since functions are just like variables, they can be returned from a function!

def outer_layer():
  print 'This is outer layer'
  def inner_layer():
    print 'This is inner layer'
  return inner_layer

def __name__ == '__main__':
func_obj = outer_layer() # func_obj now becomes inner_layer, and This is outer layer is printed on the screen.
func_obj()

Output:

This is outer layer
This is inner layer






def countdown(n):

   if n <= 0:

     print('Blastoff!')

   else:

     print(n)

     countdown(n-1)

Write a new recursive function countup that expects a negative argument and counts “up” from that number. Output from running the function should look something like this:

>>> countup(-3)

-3

-2

-1

Blastoff!

Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)

If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero.

Provide the following.

  • The code of your program.
  • Output for the following input: a positive number, a negative number, and zero.
  • An explanation of your choice for what to call for input of zero.

Create a program that asks the user to input 5 numbers. The numbers should be stored in a list, after which, your program should determine the lowest number on the list using a loop then it will display the lowest number.

Create a program the user will input 5 grades (choose any subjects and input any grades). Determine individual subjects either passed or failed. Lastly, calculate the average grade and determine whether if passed or failed.





Sample output:



Student Name: Jessica




Math: 74 - Failed



Science: 89 - Passed



English: 74 - Failed



*If the average grade is >= 75


the output should be



PASSED!



*If the subject grade is below 74 the output should be



You need to re-take in Math Subject and English Grade



*If the average grade is <= 74 the output should be



YOU FAILED!

Write a function in this file called nine_lines that uses the function three_lines (provided below) to print a total of nine lines.

Now add a function named clear_screen that uses a combination of the functions nine_lines, three_lines, and new_line (provided below) to print a total of twenty-five lines. The last line of your program should call first nine_lines and then the clear_screen function.

The function three_lines and new_line are defined below so that you can see nested function calls. Also, to make counting “blank” lines visually easier, the print command inside new_line will print a dot at the beginning of the line


LATEST TUTORIALS
APPROVED BY CLIENTS