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

Given an integer N as a starting number and K as input, write a python program to print a number pyramid of K rows as shown

In the example, the given starting number is

10, and the number of rows in the pyramid is 5.So, the output should be

10

11 12

13 14 15

16 17 18 19

20 21 22 23 24


Build an algorithm to parse and process the dynamic expression based on the dictionary

provided. The expression basically consists of Operators, Variables, and Parentheses.

Parentheses have higher precedence (i.e the subexpression in the parentheses should be

executed first)

Basically, the algorithm should support two operators - AND (concatenates the two variables) &

OR (provides first variable value if it is available. Otherwise, go for the second variable)

The algorithm should parse the given expression and apply the respective dictionary values on

the expression and provides the respective computed results.

INPUTS OUTPUT

Sno Expression Dictionary Expected Results

1 A and B

2 A and C

3 D or B

4 A or B

5 A and B and C {'A':'Hello', 'B': 'World', 'C': 'Buddy'}

6 A and (B or C) {'A':'Hello', 'B': 'World', 'C': 'Buddy'}

7 A and (C or D) {'A':'Hello', 'B': 'World', 'C': 'Buddy'}

8 A and (B or C) and D {'A':'Hello', 'C': 'Buddy', ‘D’: ‘Welcome’}


Numbers To Words Problem


Program to convert a given number to Dollar format

Write code to convert a given number into dollar format. For example, if “1234567” is

given as input, the output should be “one million two hundred thirty-four thousand

five hundred sixty-seven dollars”. Code should be able to provide output up to 1

billion.


Numbers To Words Problem

Program to convert a given number to Dollar format
Write code to convert a given number into dollar format. For example, if “1234567” is
given as input, the output should be “one million two hundred thirty-four thousand
five hundred sixty-seven dollars”. Code should be able to provide output up to 1
billion.

Trapezium Order

You are given an integer

N. Print N rows starting from 1 in the trapezium order as shown in the output of the below examples.Input

The input contains an integer

N.Output

The output should have

N lines. Each of the N lines should have space-separated integers as per the trapezium order.


      


The output should contain N space-separated integers representing the number of people who played after the person and scored less than the person.

def smaller_scores(L:list, N:int):

s = [0 for i in range(N)]

for i in range(N-1):

for j in range(i+1,N):

if L[i] > L[j]:

s[i] += 1

print(*s)

while True:

try:

N = int(input())

L = list(map(int,input().split()))

if len(L) != N:

raise ValueError

except ValueError:

print('incorect input, try again')

continue

smaller_scores(L,N)


The above program throws an error:

  N = int(input())

EOFError: EOF when reading a line

COuld you please help me to get an expected output?


Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.
Consider two classes to store the names of people. Class NAME will store the name in upper case and Class name will store in lower case. Write a program to convert the uppercase name to a lowercase name.

Consider two classes to store the names of people. Class NAME will store the name in upper case and Class name will store in lower case. Write a program to convert the uppercase name to a lowercase name. 


Area of Rectangle
Given an MxN matrix filled with 
X's and O's, find the largest rectangle containing only X's and return its area. If there are no Xs in the entire matrix print 0.
Input
The first line of input will be containing two space-separated integers, denoting M and N.
The next M lines will contain N space-separated integers, denoting the elements of the matrix.
Output
The output should be a single line containing the area of the maximum rectangle.
Explanation
For example, if the given M, N and elements of matrix are as the following
4 5
X O X O O
X O X X X
X X X X X
X O O X O
The matrix from indices (1, 2) to (2, 4) has the maximum rectangle with 
X. So the output should be the area of the maximum rectangle with X, which is 6.
Sample Input 1
4 5
X O X O O
X O X X X
X X X X X
X O O X O
Sample Output 1
6
Sample Input 2
3 3
O X X
O X X
O O O
Sample Output 2
4
LATEST TUTORIALS
APPROVED BY CLIENTS