New course! Every coder should learn Generative AI!
Try a free lesson+ 16
For i in range(-4,5):
print((5-abs(i))*"*")
+ 7
HungryTradie ☺☺ nope...it is standard
Here is the code
https://code.sololearn.com/cjyvhIfWmen1/?ref=app
+ 5
Dang Oma, nicely pythonic . (Your first i capitalised, darned auto-cucumber got you there!)
Do we need to import math to get absolute?
0
Then you should have re-learned the lessons.
and have practiced loops...
0
Python:
👉in range() # requires at least 1 argument, the "stop value", can also have start value & step value.
👉in range(7) #has only stop value as 7. Gives numbers from 0 to the number before 7, eg: 0,1,2,34,5,6
👉in range(2,5) #has both start and stop value. Starts at 2, stops at number before 5. Eg: 2,3,4
👉in range(1,7,2) #has start, stop, and step values. Step is +2 in this example. Eg: 1,3,5
Without start, range assumes you mean start from 0. Without a step value, range assumes you mean step is +1.
Python uses
👉 for variable in range(start, stop, step):
as a loop. It tests if the variable is still part of that range of numbers and iterates/runs the loop indented code again if it is. Ends the loop if the variable exceeds the range (or otherwise isn't in that set of numbers/items).
0
Oma Falk & Nell.Py ...
I can put the code in one line with a list comprehension:
https://code.sololearn.com/cM97QJNU6r7M/?ref=app