Assignment 6 - Pattern Creation
Assignment 6 - Pattern Creation
Pattern Creation
The students must complete the classwork tasks in the lab class to obtain the lab performance
marks. They will also be marked based on the assessment tasks. The lab instructors may
show/explain a few of the classwork tasks to the students if necessary. Any plagiarism in
classwork or homework will lead to the student getting zero in the entire assignment. A random
viva may take place.
You must not hard code any of the tasks, which means your code should work for any
valid user input.
Classwork
1. Take the length and width of a rectangle from the user and create the rectangle according
to the output below. Your output should match the specified output.
Output Output
1234 123
1234 123
1234 123
1234 123
1234 123
1234
2. Take the height of a left-justified right triangle from the user and create the triangle
according to the output below. Your output should match the specified output.
Output Output
1 1
12 12
123 123
1234
3. Take the height of a right-justified right triangle from the user and create the triangle
according to the output below. Your output should match the specified output.
Output Output
4 3
34 23
234 123
1234
4. Take the height of an isosceles triangle from the user and create the triangle according to
the output below. Your output should match the specified output.
Output Output
1 1
123 123
12345 12345
1234567
Evaluation
1. Take the length of a square from the user and create the square according to the output
below. Your output should match the specified output.
Output Output
1234 123
1234 123
1234 123
1234
2. Take the height of a right-justified right triangle from the user and create the triangle
according to the output below. Your output should match the specified output.
Output Output
1 1
12 12
123 123
1234
Homework
1. Take the length and width of a rectangle from the user and create a rectangle according
to the output below. Your output should match the specified output.
Output Output
4321 321
4321 321
4321 321
4321 321
4321 321
4321
2. Take the height of a palindromic isosceles triangle from the user and create the triangle
according to the output below. Your output should match the specified output.
Output Output
1 1
121 121
12321 12321
1234321
3. Take the length and width of a hollow rectangle from the user and create the rectangle
according to the output below. Your output should match the specified output.
Output Output
123456 123
1 6 1 3
1 6 1 3
123456 1 3
123
4. Take the height of a left-justified hollow right triangle from the user and create the
triangle according to the output below. Your output should match the specified output.
5. Take the height of a hollow isosceles triangle from the user and create the triangle
according to the output below. Your output should match the specified output.
1 1 1
1 3 1 3 123
1 5 12345
1234567
Follow the diagram of a rhombus below to answer questions 6 and 7. For these questions, you
will be taking the length of the blue marked area (user input).
6. Take the vertical diagonal length of a rhombus from the user and create the triangle
according to the output below. Your output should match the specified output.
Output Output
1 1
123 123
12345 12345
1234567 123
12345 1
123
1
7. Take the vertical diagonal length of a hollow rhombus from the user and create the
triangle according to the output below. Your output should match the specified output.
Output Output
1 1
1 3 1 3
1 5 1 5
1 7 1 3
1 5 1
1 3
1