Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
24th Mar 2022, 4:06 AM
Arnav Gumber
Arnav Gumber - avatar
+ 16
For i in range(-4,5): print((5-abs(i))*"*")
24th Mar 2022, 7:20 AM
Oma Falk
Oma Falk - avatar
+ 7
HungryTradie ☺☺ nope...it is standard Here is the code https://code.sololearn.com/cjyvhIfWmen1/?ref=app
24th Mar 2022, 7:27 AM
Oma Falk
Oma Falk - avatar
+ 5
Dang Oma, nicely pythonic . (Your first i capitalised, darned auto-cucumber got you there!) Do we need to import math to get absolute?
24th Mar 2022, 7:24 AM
HungryTradie
HungryTradie - avatar
+ 1
G'day Nell.Py what can you say about range in Python? Next question, will you want to do this in just one loop, or can you use two different loops? Do you have some idea of the logic you will use (share it here)? Or better yet, share a SoloLearn "code bit" of your attempt so far.
24th Mar 2022, 4:54 AM
HungryTradie
HungryTradie - avatar
0
Then you should have re-learned the lessons. and have practiced loops...
24th Mar 2022, 4:44 AM
NEZ
NEZ - avatar
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).
24th Mar 2022, 5:14 AM
HungryTradie
HungryTradie - avatar
0
Oma Falk & Nell.Py ... I can put the code in one line with a list comprehension: https://code.sololearn.com/cM97QJNU6r7M/?ref=app
25th Mar 2022, 9:28 PM
Raffaele Bisogno
Raffaele Bisogno - avatar