Define a function below called average_strings. The function takes one argument: a list of strings. Complete the function so that it returns the average length of the strings in the list. An empty list should have an average of zero. Hint: don't forget that in order to get a string's length, you need the len function.

Answers

Answer 1
Answer:

The required code written in python 3 which returns the average of the strings in a list goes thus :

def average_strings(string_list):

#initializeafunctionnamedaverage_stringwhichtakesinalistofstringasparameter

total_length = 0

#initializetotallengthofstringto0

if len(string_list)==0:

#checksofthe stringisempty

return 0

#ifstringisemptyreturn0

for word in string_list :

total_length += len(word)

#addthelength ofeachstringtothetotallengthofthe string.

return total_length / len(string_list)

#returntheaveragevalue

A sample run of the function is given here and the output attached.

string_list = ['dog', 'cat', 'mouse']

print(average_strings(string_list))

Learn more :brainly.com/question/15352352

Answer 2
Answer:

Answer:

def average_strings(lst):

   total = 0

   if len(lst) == 0:

       return 0

   for s in lst:

       total += len(s)

   return total / len(lst)

Explanation:

Create a function called average_strings that take one parameter, lst

Initialize a total to hold the length of the strings in lst

If the length of lst is 0, return 0

Otherwise create a for loop that iterates through the lst. Calculate the length of each string in lst and add it to total

When the loop is done, return the average, total length of the strings divided by length of the lst


Related Questions

The string expression strVar.____________________ starts at index pos, replaces the next n characters of strVar with all the characters of str.
What is the tool that is used to automatically search New information on the internet and organize if for future searches?
Object-oriented programming allows you to derive new classes from existing classes. This is calledcomposition.interfaces.inheritancepolymorphism
what are "open source" programming language? Give examples of open source languages. Discuss the pros and cons of open source language.
codes with three characters are included in the icd-10-cm as the heading of a of codes that may be further subdivided by the use of 4th, 5th, or 6th characters, which provide greater detail.

How do you suppose the Anagram Server works?

Answers

Answer:

 The anagram is the type of word and phase that are formed by the rearranging the another letter with the word and phase.

The anagram is the type of network server that produce the anagram and it is use as the code and pseudonyms.

If the anagram is create by someone then, the person is known as anagrammatist. Its main goal is to produce the anagram which reflect on their particular subject. The anagram word can also be represented or rearranged into the nag a ram.

Which of the following statements describes a limitation of using a computer simulation to model a real-world object or system?a. Computer simulations can only be built after the real-world object or system has been created.
b. Computer simulations only run on very powerful computers that are not available to the general public.
c. Computer simulations usually make some simplifying assumptions about the real-world object or system being modeled.

Answers

Answer:

The answer is "Option c".

Explanation:

Computer simulation, use of a machine to simulate a system's vibration signals by another modeled system's behaviors. A simulator employs a computer program to generate a mathematical model or representation of a true system. It usually gives a lot of simplifications concerning the physical image or system that is modeled, so this statement describes the limitation of using a computer simulation in modeling a real-world object or process.

Two-factor authentication can best be breached by the adversary using:________. a. social engineering attack b. using sniffers like Wireshark and capturing packets c. using rootkits and privilege escalation to get to the kernel processes d. using a virus and destroying the computer that stores authentication information.

Answers

Answer:

a. social engineering attack

Explanation:

Two-factor authentication requires that the user/owner of the account enter a second verification code alongside their password in order to access the account. This code is usually sent to a personal phone number or email address. Therefore in order to breach such a security measure the best options is a social engineering attack. These are attacks that are accomplished through human interactions, using psychological manipulation in order to trick the victim into making a mistake or giving away that private information such as the verification code or access to the private email.

Integer userNumber is read from input. Write a while loop that multiplies userNumber by 4, updating userNumber with the product, and outputs the updated userNumber, followed by a newline. The loop iterates until userNumber is greater than or equal to 40.Ex: If the input is 25, then the output is:

100

import java.util.Scanner;

public class ProductCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userNumber;

userNumber = scnr.nextInt();
while(userNumber >= 40){
userNumber = userNumber * 4;
System.out.println(userNumber);
}
Java. What am I doing wrong? It's not giving an output.

}
}

Answers

Change this line;

  • while(userNumber >= 40)

with;

  • while(userNumber <= 40)

The loop will never start because userNumber is not already greater than 40.

No Browsing History While using the browser on your tablet, you realize that it is not keeping a history of websites you have visited. Why might this be happening, and what is the first step you will take to correct this problem? Phishing Scam You just received an email message from someone requesting personal identification information. Believing the message was legitimate, you provided the requested information to the original sender. You now realize, however, that you might have fallen victim to a phishing scam. What are your next steps? Suspicious File Attachment You receive an email message that appears to be from someone you know. When you try to open the attachment, nothing happens. You attempt to open the attachment two more times without any success. Several minutes later your computer is running slower and you are having trouble running apps. What might be wrong? Antivirus Software Outdated After starting your computer and signing in to the operating system, a message is displayed stating that your virus definitions are out of date and need to be updated. What are your next steps? Laptop's Physical Security You plan to start taking your laptop to school so that you can record notes in class. You want to make sure, however, that your computer is safe if you ever step away from it for a brief period of time. What steps can you take to ensure the physical security of your laptop?

Answers

  • The steps a person can take to ensure the physical security of your laptop is to;
  • Always use a firewall.
  • Make sure your software up to date.
  • Use antivirus software

How can a person  physically secure their laptop?

A lot of laptops and desktop computers are known to have built-in slots that can connect with a cable lock.  A person can keep their Laptops from getting Lost or stolen by;

  • Keeping it locked.
  • Keeping it off the floor, etc.

learn more about laptop  from

brainly.com/question/21283135

Answer & Explanation:

No Browsing History:

  • Your browser is probably set to incognito mode, change it to general mode.
  • space set on your drive to save the content from your browser might be completely filled, Make sure you have given your browser enough space on your drive to save contents.
  • The number of days to record the history in your browser is set to 0, Check the settings and make sure it is not set to 0.

Phishing Scam

  • Change all the credentials on the site that you have disclosed.
  • Immediately report the mail to an IT department and necessary authorities.
  • Mark the mail as span and block the mail id.

Suspicious File Attachment

  • May be that the suspicious file contains a virus file. Often such viruses are attached to external "Show-case" files so that the victim is not able to identify them. Once the external file is tried to open, the virus slips into the main memory (your RAM) and start executing in the background, creating copies of itself and executing every copy. Soon they start eating up the main memory (The memory that runs all your programs) making your PC slow to respond.

Antivirus Software Outdated

  • Connected to the Internet and update the antivirus.

Laptop's Physical Security

  • Set a password.
  • install a tracking software.

3. Problem 5. A digital computer has a memory unit with 24 bits per word. The instruction set consists of 150 different operations. All instructions have an operation code part (opcode) and an address part (allowing for only one address). Each instruction is stored in one word of memory. a. How many bits are needed for the opcode? b. How many bits are left for the address part of the instruction? c. What is the maximum allowable size for memory? d. What is the largest unsigned binary number that can be accommodated in one word of memory?

Answers

The number of bits that are needed for this operation code (opcode) is 8 bits.

What is binary encoding?

Binary encoding can be defined as a standard technique that is designed and developed for converting data in plain text (source alphabets) to a form that is easily used by different operating systems (OS), especially through the use of a binary digit (bit) or two-symbol system.

How to calculate the number of bits.

The number of bits that are needed for this operation code (opcode) is given by this mathematical expression:

2^n > 150\n\n2^8 > 150\n\n256 > 150

n = 8 bits.

b. To determine the number of bits that are left for the address part of the instruction:

  • Opcode, O, I = 8 bits.
  • Instruction size = 24 bits.

Address = I-O\n\nAddress =24-8

Address = 16 bits.

c. To determine the maximum allowable size for memory:

Based on the memory unit, this is given by 2^(16)* 24

d. The largest unsigned binary number that can be accommodated in one word of memory is given by: 2^(24)-1

Read more on binary encoding here: brainly.com/question/5381889

Answer:

a) 8 bits b) 16 bits. c) 2¹⁶ * 24 bits d) 2²⁴ -1

Explanation:

a) In order to be able to accommodate 150 different instructions, the number of bits needed must be equal to the minimum power of 2 that satisfies this equation:

2n > 150, i.e. n=8.  

b) If the total number of bits for a word is 24, and 8 are used for the op code, there are 16 bits left for the address part.

c) If the address part has 16 bits, this means that the total addressable space is just 2¹⁶, so the maximum allowable size is 2¹⁶ * 24 bits.

d) As we have 24 bits to be filled, the largest unsigned binary number is just 2²⁴ – 1.

(As we need to leave a position for all zeros).