Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Find reliable answers to your questions from a wide community of knowledgeable experts on our user-friendly Q&A platform. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
Sagot :
Answer:
def swap (ar, a, b):
temp = ar[a]
ar[a] = ar[b]
ar[b] = temp
terms = ["Bandwidth", "Hierarchy", "IPv6", "Software", "Firewall", "Cybersecurity", "Lists", "Program", "Logic", "Reliability"]
print(terms)
for i in range(len(terms)):
for j in (range(i, len(terms))):
if(terms[i] > terms[j]):
swap(terms, j, i)
print(terms)
Explanation:
I got 100% on edhesive.
The code practice requires the uses of loops and conditional statements.
Loops are used for repetition of operations, while conditional statements are used for making decisions.
The sort program in Python, where comments are used to explain each line is as follows:
#This defines the swap function
def swap (terms, a, b):
#This creates a temporary variable
temp = terms[a]
#The next two lines swap the elements
terms[a] = terms[b]
terms[b] = temp
#This initializes the list
terms = ["Bandwidth", "Hierarchy", "IPv6", "Software", "Firewall", "Cybersecurity", "Lists", "Program", "Logic", "Reliability"]
#This prints the list before sorting
print(terms)
#This calculates the length of the list
n = len(terms)
#This iterates through the list
for i in range(n):
#This iterates through every other element of the list
for j in (range(i, n)):
#This swaps the elements
if(terms[i] > terms[j]):
swap(terms, j, i)
#This prints the list after sorting
print(terms)
Read more about sort programs at:
https://brainly.com/question/15263760
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Your questions are important to us at Westonci.ca. Visit again for expert answers and reliable information.