Can anyone help me with the Python code?
Field = [5,4,3,4,5,6]
for i in range(6):
if Field[i]>Field[i+1]:
h = field[0]
Field[0] = Field[1]
Field[1] = h
print(field)
I want to sort the field by numbers using this procedure but it doesn't work
Field = [5,4,3,4,5,6]
for i in range(6):
if Field[i]>Field[i+1]:
h = field[0]
Field[0] = Field[1]
Field[1] = h
print(field)
I want to sort the field by numbers using this procedure but it doesn't work
Hello, I deactivated my Instagram last summer and would like to reactivate it. However, I no longer have access to the stored mobile number and I don't know my backup code. Otherwise, I still know the username, the old password and the email. I already wrote to Instagram support but no response. Thank you
I would really like to know when/why you learned to program. Or generally IT It is only for people who have programmed before
I'm supposed to download a website from my mother because the costs are too high for her to get it to show up on Google or whatever, it doesn't matter. How do you download a website from Firefox to a PC so that the website is on the PC? thank you for your answers
I really like ChatGPT but the unpaid version unfortunately has no internet access. Do you know of any similar artificial intelligences like ChatGPT that have access to the Internet?
Good day, I'm currently working on a project that requires me to use real data. I found a CSV file that presents innovative projects from Vienna. I'm currently trying to convert the file to UTF8 and then enter it into Mockaroo as a dataset. But it doesn't work. I've already tried shortening the file so…
When I pass root.left from add to add(data, parent), I'm not passing the reference to this object so that it gets changed, but only a kind of copy that has no reference to my root. How do I work around this? A beginner's programming language should be able to do this. public class Tree {…
First, you have ifs [0] and [1] instead of [i] and [i+1] used, that is already wrong.
Second, you need Member State and not ). Otherwise, i+1 is an invalid index.
Thirdly, this only brings the greatest number to the right end.
Imagine the 6 would be left. Now go through the code piece by piece:
You are comparing the first number with the second one and if the first one is larger. The 6 is now second. Now you compare the second place with the third and exchange it. 6 is only in the third place. etc. You just take the largest number to the right.
To sort the complete list with this procedure, you need another loop to repeat the whole thing:
You could still optimize the code by not always letting the inner loop run completely to the end, because the numbers on the right are already sorted. But I’ll save you, the code is running anyway? 😀
In Python you do not need an auxiliary variable for a swap
Field[i+1],Field[i] = Field[i],Field[i+1]