Answered>Order 17803

This is python programming

Q2.  40 points Patterns:

Ask the user to enter a number a number n.  Output the illustrated pattern depending on n as shown below.

Sample Output 1:

Please enter n: 3

o

oo

***

o

**

ooo

*

oo

ooo

Sample Output 2:

Please enter n: 4

o

oo

ooo

****

o

oo

***

oooo

o

**

ooo

oooo

*

oo

ooo

oooo

Q3.  40 points Problem Statement:

Ask the user to enter a sequence of numbers. Let’s call this sequence A. Thereafter ask the user to enter a sequence of numbers B which indicates positions which are least important. We generate a sequence as follows:

The least important numbers specified by B must be at the end and in the same order as they were in A.

The remaining number from A are to be sorted in descending order.

Sample Output 1:

Please enter A:  9 3 1 20 11 0

Please enter B: 3 6

The sequence you want is:  20 11 9 3 1 0

The numbers at positions 3 and 6, 1 and 0. They are at the end and in the order, they appeared in list A. The other numbers are sorted in descending order.

Sample Output 2:

Please enter A: 9 3 1 20 11 0

Please enter B: 1 6

The sequence you want is: 20 11 3 1 9 0

The numbers at positions 1 and 6 are 9 and 0 respectively. They are at the end and in the order, they appeared in list A. The other numbers are sorted in descending order.

Sample Output 3:

Please enter A: 9 3 1 20 11 0

Please enter B: 1 4 6

The sequence you want is: 11 3 1 9 20 0

The numbers at positions 1, 4 and 6 are 9, 20 and 0 respectively. They are at the end and in the order, they appeared in list A. The other numbers are sorted in descending order

 
"Not answered?"
Get the Answer