#python loop
Explore tagged Tumblr posts
szimmetria-airtemmizs · 1 year ago
Text
Tumblr media
Balance
1K notes · View notes
nostalgebraist · 7 months ago
Text
Due to recent experiences, I am feeling an urge to make an anti-drug-style PSA except it's warning impressionable machine-learning-curious teens to never, ever try a thing called "Huggingface transformers Trainer"
Not. Even. Once.
81 notes · View notes
Text
Unmute the loop!
123 notes · View notes
powerwithinart · 2 months ago
Text
potent.
12 notes · View notes
angletelier · 3 months ago
Text
I love replying to Tumblr comments :3
*is hiding in the bathroom avoiding doing my python coding homework*
3 notes · View notes
rickybutlersays · 2 years ago
Text
please god please PLEASE say that someone else ships Lemming and Stapleton from monty python
33 notes · View notes
helloworldletscode · 8 months ago
Text
Iterations - for loop
Iteration, aka repeating, is a solution for tasks that need to be done over and over again.
Instead of writing dozens of lines of code for the same purpose, we can simplify it and shorten it to just a couple of lines. This way the code is both easier to read for the other programmers (fellow people hehe) and faster to process for the computer.
Also, simpler code reduces errors rate.
Examples of iterations are loops.
Looping means repeating something until a particular condition is satisfied. 
Python has 3 Basic Loops:
For Loop - used when we know number of iterations (repetitions) in advance.
While Loop - for situations where the number of iterations is unknown beforehand. 
Nested Loop - using one looping statement inside another looping statement.
For loop is used to execute the same instruction over and over again, a specific number of times.
for i in range(5):     print(“Hello!”) Output: Hello! Hello! Hello! Hello! Hello!
In the first line, we declared how many repetitions are needed. In the second line, we wrote what should be repeated a given number of times. In this case, we asked Python to print the string “Hello!” 5 times.
Basic structure of the for loop:
for i in range(5):     print(“Hello!”)
for - a keyword that signals that “for loop” is starting.
i - internal variable name which is keeping the counter value. Stands for “iteration”. We can read the whole line as “for 5 iterations/repetitions, please do the following:” For every loop, the 'i' variable increases by 1 because it's the counter. 'i' doesn't have to be 'i', we can switch it to another letter or another word, that are python approved for this (for example, you can’t use name of defined function instead of 'i').
#Loop using "unicorn" as internal variable, instead of "i" for unicorn in range(10): print(unicorn) #still works!
  in range() - represents the list of numbers we are looping through (number of time the iteration is running). Python starts the counter from 0. It means that range(5) -  will give a sequence of 5 numbers: 0, 1, 2, 3, 4 range() function has 3 parameters(start, end, steps), default values for start is 0 and step is 1. When we write range(5), we only give one parameter, and the function still works, because Python reads it as range(0,5,1) and the sequence starts with 0, increases by 5 counts, with step between each number being 1, by default.
We can change the parameters: range(1,20,3) this would result in iterations that starts from 1, goes up by 3 steps with the upper limit of 20: 1, 4,7,10,13,16,19.
Example: #print every 2 numbers (evens): for i in range (2, 10, 2):     print(x) output: 2 4 6 8 (!) output does not include 10 because 10 is the upper limit (result only includes number under 10)
: adding a colon sign in the end of the first line is mandatory, otherwise an error will occur.   Finally in the next line, we start writing the instruction, that is supposed to be repeated. This part isn’t starting right away, it should be indented. Indentation is the blank gap at the beginning of lines. Normal indentation is 4 spaces/tab long. Python would recognize 2 spaces or 4 spaces as an indentation, but 4 spaces length is more agreed upon and is used more wildly.
tip: How to write an instruction to get output of a list that starts from 1 instead of 0, accompanied by a string:
for i in range(10):     print(i+1, "I love you")
4 notes · View notes
fortune-slip · 5 months ago
Text
I'm taking a class on like. advanced data structures and blah blah whatever blah. riveting stuff. Anyway one the main things we're being taught in the class is runtime optimization which makes sense. but like. why is it being taught in python of all languages
2 notes · View notes
Text
Python Interpreter Loop Counter
3 notes · View notes
szimmetria-airtemmizs · 6 months ago
Text
Tumblr media
On the sides you can see two curves of constant width, that is a curve whose width is the same in all directions. This is the reason they always touch the two lines as they rotate. The existence of curves of constant width is well known by now. What is much less known is that you can morph between any two such curves such that during the morph the curve stays a curve of constant width. For these two curves the morphing can be seen in the middle. (Actually, you can see two different morphs. )
294 notes · View notes
doedipus · 1 year ago
Text
the difference between my enthusiasm after one day of the japanese class and my enthusiasm after one day of the programming class are night and fucking day, to the extent I'm considering just dropping the programming one on the spot
7 notes · View notes
auncyen · 10 months ago
Text
reading a programming book that is using a program that simulates rock paper scissors as the tutorial for loops and it's just. ah. this is me associating ISAT with unrelated things now
6 notes · View notes
allenmmmm · 1 year ago
Text
Python Loops Tutorial | Loops In Python | Python Loops Tutorial for Beginners
Let's go through a basic tutorial on loops in Python. This tutorial is designed for beginners, and we'll cover the two main types of loops in Python: for and while loops.
1. For Loop:
The for loop is used to iterate over a sequence (such as a list, tuple, string, or range).# Example 1: Iterate over a list fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) # Output: # apple # banana # cherry # Example 2: Iterate over a range of numbers for i in range(5): print(i) # Output: # 0 # 1 # 2 # 3 # 4
2. While Loop:
The while loop is used to repeatedly execute a block of code as long as the specified condition is true.# Example 3: Simple while loop count = 0 while count < 5: print(count) count += 1 # Output: # 0 # 1 # 2 # 3 # 4
3. Loop Control Statements:
break: Terminates the loop.
continue: Skips the rest of the code inside the loop for the current iteration.
else clause with loops: Executed when the loop condition becomes False.
# Example 4: Using break and continue for i in range(10): if i == 3: continue # Skip the rest of the code for this iteration elif i == 8: break # Exit the loop when i is 8 print(i) else: print("Loop completed") # Output: # 0 # 1 # 2 # 4 # 5 # 6 # 7
4. Nested Loops:
You can use loops inside other loops.# Example 5: Nested loops for i in range(3): for j in range(2): print(f"({i}, {j})") # Output: # (0, 0) # (0, 1) # (1, 0) # (1, 1) # (2, 0) # (2, 1)
This is a basic introduction to loops in Python. Practice with different examples to solidify your understanding. In Part 2, you can explore more advanced concepts and practical applications of loops in Python.
Watch Now: -The Knowledge Academy
2 notes · View notes
relto · 2 years ago
Text
optimization journey: glue 10000+ arrays together for each data channel -> reduce number of array glueing required by doing 32 sequences at once -> NO array glueing at all!
3 notes · View notes
themaskofreason · 2 years ago
Text
someone remind me at like 6pm bst to put more brackets in the queue i only did enough to cover until tonight
2 notes · View notes
aquietnerd · 24 days ago
Text
Anyway.
On another note. If every time they change something in the Matrix, you get something similar to a cat repeatedly appearing in a hallway. Do you there's instances of you think you seen Agent Smith. You look back, nothing. Look back again, THERE HE IS NOTHERFUCKER
1 note · View note