COMP1010 Lab07 1
COMP1010 Lab07 1
Submission Instructions:
• Students must submit Lab Practice 07 on
Canvas and Codeforces with the correct
file names during the lab session.
*
***
*****
*******
*********
Write a Python program that takes an integer n as input and draws the n-row hollow pyramid.
Input Format:
Player list: A single integer n which satisfies 3 ≤ n ≤ 100.
Expected Output:
A solid star pyramid composed of n rows, with each row containing an increasing number of asterisks.
Example:
Test case 1
Input:
3
Output:
*
***
*****
Test case 2
Input:
6
Output:
*
***
*****
*******
*********
***********
Input Format:
A list of positive integers, separated by space, having length from 1 to 100. Each integer has ranges from
−105 to 105 .
This way shows while loop’s strengths in handling conditions that are not tied to the length of the list.
Expected Output:
Output the smallest positive integer missing from the list using two lines: the first line employs a for
loop, while the second utilizes a while loop.
Example:
Test case 1
Input:
3 4 -1 1
Output:
2
2
Test case 2
Input:
10 9 8 7 6 5 4 3 2 1
Output:
11
11
Input Format:
The input has a single string where each character represents a step and can be either U (up) or D (down).
This string’s length ranges from 3 to 104 .
Expected Output:
An integer representing the number of valleys traversed in the given string.
Example:
Test Case 1:
Input:
UDDDUUUD
Output:
1
Test Case 2:
Input:
DUDDDUUDDUUUDD
Output:
2
Test Case 3:
Input:
UDDDUUUUUUDDDUDDD
Output:
1
1. Insert a Player: Add a new player along with their score to the system. The operation is formatted
as insert PlayerName Score within the operations string.
2. Remove a Player: Remove a player from the system by their name. The operation is formatted
as remove PlayerName within the operations string.
3. Adjust a Player’s Score: Modify the score of an existing player, either increasing or decreasing
it. The operation is formatted as adjust PlayerName ScoreChange within the operations string.
Input Format:
Player list: The first line contains a single string including players and their scores in the format
PlayerName Score, separated by commas.
Operation list: The second line contains a single string including operations, where each operation is
represented in the format operation operation PlayerName [Score or Nothing], separated by com-
mas.
Note: The score of both the input and in each operation ranges from −1000 to 1000.
Expected Output:
Print the list of players (name only) sorted from highest to lowest score. For players with the same score,
print them in alphabetical order by name.
Example:
Test case 1
Input:
Thinh 1500, Anh 1200, Tuan 1300
insert Wong 1400, remove Anh, adjust Wong -200
Output:
Thinh Tuan Wong
Test case 2
Input:
Phuc 1500, Vinh 1500, Mien 1500
insert Thinh 1400, adjust Phuc -100, adjust Vinh -100, adjust Mien -100
Output:
Mien Phuc Thinh Vinh