+ 4
Help plss!!
What’s it’s output and how I can identify? What is the output of this code? y=[x for x in range(10) if x//3==2] print(sum(y)) Sorry Doom Slayer I’m beginner :/
18 Respuestas
+ 7
Welcome!
Practice, learn, and don't give up!
+ 6
🇮🇱 Radin Masiha 🇮🇱 ,
the code that is executed has a for loop inside, but it is called a *list comprehension*.
+ 5
Yes I think Python is one of the most useful languages, but you should think why are you learning programming first? What do you want to code!? Then choose your language depending on your aim.
All in all, I suggest you to continue learning Pyrhon, and become an expert (enough). Then you can start other languages if neede.
+ 4
Nice, no problem.
Here you've declared a variable called "y" and assigned it to a loop. You've defined "x" in range 10, which means whole numbers from 0 to 9. But there is a condition for it, you've said "x//3==2" which means those "x"es that the floor division of them equals to 2. So the numbers will be "6,7,8".
Then you've printed the sum which outputs: 6+7+8=21
I'm not a Python expert, but I hope I was helpful. Any other questions? Don't hesitate to ask!
(P.S. I'm not Doom Slayer, I am a Spartan 😄😄)
+ 4
The answer would be 21 because
y = [6,7,8]
y includes all the numbers that would result in 2 when floor divided by 3. Sum of all the numbers would be 21.
+ 3
"Insert" your code here.
Please don't expect us to guess your code
+ 3
What’s it’s output and how I can identify?
What is the output of this code? y=[x for x in range(10) if x//3==2] print(sum(y))
Sorry Doom Slayer I’m beginner :/
+ 3
And to add a tip, make sure you tag your relevant programming language (here Python) under your question.
+ 3
Eloísa Mendonça Martins ,
If you have some code, and you want to see what its output is, the first thing you should do is run it and look at the output.
Do you need help about how to create a new program on Sololearn?
+ 3
Thank you for all help! :)
+ 2
Thank you! I will study more python, I’am very begginer in programming :)
+ 1
One question, do you know if the best programming language to learn from the beginning is Python, I'm learning the concept and how it works
+ 1
Who can write code that removes the marker from the photo
+ 1
21
easy bruh
+ 1
Elyor Khaitov ,
If your reply was to Bdhz Hzhd , don't bother, because all they did was copy and paste the opening message of the thread creator. They weren't asking a real question.
And Milad Hamidi already said it was 21 and explained why anyway.