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

You are given an m*n matrix.write a program to compute the perimeter of the matrix and print the result.Perimeter of a matrix is defined as the sum of all elements of the four edges of the matrix.


Input

The first line of input containing the positive integer.

The second line of input containing the positive integer.

The next N lines of input space-separated integers.



Explanation

The input should be

3
4
1 2 3 4
5 6 7 8
9 10 11 12


The output should be 1+2+3+4+8+12+11+10+9+5 = 65


Sample Input1

3

4

1 2 3 4

5 6 7 8

9 10 11 12


Sample Output1

65



Write a program to print a parallelogram pattern with * characters. The size N represents the length (the number of * characters in each line)& breadth ( the number of lines) of the parallelogram.

The slope of the parallelogram T represents the number of extra spaces a line should have in the beginning compared to its next line. The last line of the pattern does not have any spaces in the beginning.


Explanation:

Given N=3 and T=2

Each line should have 3 star(*) characters.

The last line should have 0 spaces at the beginning.

Each line has 2 extra spaces characters when compared to its next line.


Sample Input1

2

2

Sample Output1

**

**

Sample Input2

3

2

Sample Output2

***

***

***


Akshya is given a list of N integers. Each number in the list appears exactly for one number. help akshya by identifying the numbers which appeared exactly once in the list.


Input

The input contains a single-line comma-separated integers.


Output

The output contains a single-line comma-separated integers.


Sample Input1

8,9,5,8,5,6


Sample Output1

9,6


Sample Input2

1,2,3,4,5,1,2,3,4

Sample Output2

5


Andy has the word W and he wants to print the unique characters in the word in the order of their occurrence.write a program to help Andy print the unique characters as described above.


NOTE : consider lower and upper case letters as different


Input

The input is a single line containing the word W.


Output

The output should be a single line containing space separated characters.


Explanation

In the example, the word is MATHEMATICS

The unique characters in the given word are M, A, T, H, E, I, C, S, in the order of occurrence.so the output should be M A T H E I C S.


Sample Input1

MATHEMATICS

Sample Output1

M A T H E I C S


Sample Input2

banana

Sample Output2

b a n


Write a Python program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list. It should have the following functions:

  • find_lowest(list): finds and returns the lowest number in the list. Do not use any built-in function.
  • find_highest(list): finds and returns the highest number in the list. Do not use any built-in function.
  • calculate_total(list): calculates and returns the total of the numbers in the list. Do not use any built-in function.

The program should call the functions mentioned above and display the lowest, highest and total values in the list. It should also calculate and display the average of the numbers in the list


def mystery1(x):
  return x + 2

def mystery2(a, b = 7):
  return a + b

#MAIN
n = int(input("Enter a number:"))
ans = mystery1(n) * 2 + mystery2 (n * 3)
print(ans)

What is output when the user enters 3?




Write a program to accept an integer amount from user and tell minimum number of notes needed for representing that amount.

Suppose you are given two dictionaries. Now create a new dictionary "marks", merging the two dictionaries, so that the original two dictionaries remain unchanged. Note: You can use dictionary functions. =================================================================== Given: {'Harry':15, 'Draco':8, 'Nevil':19} {'Ginie':18, 'Luna': 14} Output: {'Harry': 15, 'Draco': 8, 'Nevil': 19, 'Ginie': 18, 'Luna': 14} =================================================================== Given: {'A':90, 'B': 0} {'C':50} Output: {'A': 90, 'B': 0, 'C': 50}


Using a class to represent the planet and its gravity, develop a program that outputs the user's weight on different planets.


  • The class's constructor should allow a planet to specified as a capitalized string. If the string is not a planet's name or is not capitalized, then the planet of EARTH should be assumed as the default value.
  • The default constructor for the class will create an object representing Earth. The class has a function called "convertWeight" that takes in a weight on earth as an argument and returns the name of the planet as well as the converted value reflecting weight on the given planet to console.
  • The program should output an error message and reprompt for input if the user does not input a correct planet name that is also capitalized.




Write a Python program that asks the user to enter a store’s sales for each day of the week. The sales amounts should be stored in a list. Use a loop to calculate the total sales for the week and display the result. Do not use built-in Python function like sum to perform the calculation


LATEST TUTORIALS
APPROVED BY CLIENTS