Flat Asterisk Pyramid
Part of the Fundamentals section of Coddy's Python journey — lesson 75 of 77.
Arithmetic operations can also be done on strings. For example:
str1 = "aaa" + "b"str1 will hold "aaab"
This is the same as:
str1 = "aaa"
str1 += "b"Also, we can use multiplications:
str1 = "a"*10str1 will hold "aaaaaaaaaa"
Challenge
MediumEach test case has one input - an odd whole number (always odd, given).
Your task is to print n - pyramid using *, here are some examples:
1 - pyramid
*5 - pyramid
*
***
*****7 - pyramid
*
***
*****
*******Input
- odd integer
nfrom user - 1 <=
n< 1000
Tips
- Try starting from the small triangles
- Check the hint if you are stuck ;)
nrepresents the number of*in the bottom row
Try it yourself
n = int(input())All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 48Loops
For LoopWhile LoopBreakContinueRecap - FactorialThe Range FunctionNested LoopRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators9Functions
Declare a FunctionArgumentsReturnRecap - Sigma FunctionRecap - Validation FunctionDefault Values12Iterating Over Sequences
Iterating Over ElementsThe Enumerate FunctionIterating Over Strings Part 1Iterating Over Strings Part 2