Answer to Question #295817 in Python for Alex

Question #295817

 This lab is a warm-up for the next assignment. We will learn to build a multi-threaded application. You will write a function that will simulate a long task. You will call the first method a number of times sequentially and record the time it takes to complete. They will call the first method again but in a threaded manner and time, the execution and then compare the two times. Description Create three functions:1.Create a function to the following:a.Take a string argument (name).b.Create a loop that will run 100 000 times. In this loop, the program will sleep 0.0001 seconds.c. After the completion of the loop, prints its name and a brief message.2.Create a second function to do the following:a. Takes a number argument (times to execute the loop).b.Store the current time. c.Call the function in step 1 the required number of times (sequentially).d.Check the elapsed time after the above calls are complete. e. Print the results as well as a brief message.

1
Expert's answer
2022-02-10T02:49:59-0500

1.

test_miss = ["b","zzz"] 
def missing_letters(s):
    missingAlphabets = ""
    global alphabet
    for c in s:
        i=0
        while i < len(alphabet):
            if alphabet[i] not in c:
                missingAlphabets += alphabet[i]
            i += 1
    sortedmissingAlphabetslists = sorted(missingAlphabets)
    sortedmissingAlphabets = ''.join(sortedmissingAlphabetslists)
    return sortedmissingAlphabets

for i in test_miss:
    print('{} is missing letters {}'.format(i,missing_letters(i)))

2.


class Node:
	def __init__(self, data):
		self.data = data
		self.next = None

class LinkedList:

	def __init__(self):
		self.head = None

	def count(self, search_for):
		current = self.head
		count = 0
		while(current is not None):
			if current.data == search_for:
				count += 1
			current = current.next
		return count

	def push(self, new_data):
		new_node = Node(new_data)
		new_node.next = self.head
		self.head = new_node

	def printList(self):
		temp = self.head
		while(temp):
			print (temp.data)
			temp = temp.next
llist = LinkedList()
llist.push(1)
llist.push(3)
llist.push(1)
llist.push(2)
llist.push(1)

print ("count of 1 is % d" %(llist.count(1)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS