Skip to content
🤔prompts chat🧠
🔍
question:Create a Python script to calculate the average age of a list of people. people = [ { 'name': 'John', 'age': 25 }, { 'name': 'Jane', 'age': 34 }, { 'name': 'Dave', 'age': 19 }, { 'name': 'Sarah', 'age': 21 }, { 'name': 'Henry', 'age': 29 } ]

answer:total = 0 for person in people: total += person['age'] average = total / len(people) print(f'Average age is {average}') // 24.4

question:Generate a Python program to extract the emailIDs from a text string. Example user input: The list of contacts is [email protected],[email protected],[email protected]

answer:import re text = "The list of contacts is [email protected],[email protected],[email protected]" pattern = r'[w.-]+@[w.-]+' match = re.findall(pattern, text) print(match)

question:Develop a system in Python for detecting plagiarism.

answer:import difflib def plagiarism_detector(string_a, string_b): sequence = difflib.SequenceMatcher(None, string_a, string_b) similarity = sequence.ratio() * 100 print('Similarity = {:.2f}%'.format(similarity)) plagiarism_detector('The quick brown fox', 'The quick brown fox jumps over the lazy dog')

question:mplement a basic web server using Python.

answer:import socket HOST, PORT = '', 8888 listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) listen_socket.bind((HOST, PORT)) listen_socket.listen(1) print 'Serving HTTP on port %s ...' % PORT while True: client_connection, client_address = listen_socket.accept() request = client_connection.recv(1024) print request http_response = """ HTTP/1.1 200 OK Hello, World! """ client_connection.sendall(http_response) client_connection.close()

Released under the Storm License.

has loaded