1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jok3333 [9.3K]
3 years ago
14

create your own min function that finds the minimum element in a list and use it in a separate function

Computers and Technology
1 answer:
schepotkina [342]3 years ago
5 0

Answer:

def minfunction(mylist):

   min = mylist[0]

   for i in mylist:

       if i < min:

           min = i

   print("The minimum is: "+str(min))

   

def anotherfunction():

   mylist = []

   n = int(input("Length of list: "))

   for i in range(n):

       listelement = int(input(": "))

       mylist.append(listelement)

   minfunction(mylist)

   

anotherfunction()

Explanation:

This solution is implemented in Python

This defines the min function

def minfunction(mylist):

This initializes the minimum element to the first index element

   min = mylist[0]

This iterates through the list

   for i in mylist:

This checks for the minimum

       if i < min:

... and assigns the minimum to variable min

           min = i

This prints the minimum element

   print("The minimum is: "+str(min))

   

This defines a separate function. This  separate function is used to input items into the list

def anotherfunction():

This defines an empty list

   mylist = []

This prompts user for length of list

   n = int(input("Length of list: "))

The following iteration inputs elements into the list

<em>    for i in range(n):</em>

<em>        listelement = int(input(": "))</em>

<em>        mylist.append(listelement)</em>

This calls the minimum function

   minfunction(mylist)

   

The main starts here and this calls the separate function

anotherfunction()

You might be interested in
A computer ia a personal computer you can carry from place to place​
tester [92]

Answer:

laptop is portable and wireless

5 0
3 years ago
Read 2 more answers
Write a C++ program that reads from the standard input and counts the number of times each word is seen. A word is a number of n
Rufina [12.5K]

Answer:

#include <stdio.h>

#include <string.h>

#include <ctype.h>

 

struct detail

{

   char word[20];

   int freq;

};

 

int update(struct detail [], const char [], int);

 

int main()

{

   struct detail s[10];

   char string[100], unit[20], c;

   int i = 0, freq = 0, j = 0, count = 0, num = 0;

 

   for (i = 0; i < 10; i++)

   {

      s[i].freq = 0;

   }

   printf("Enter string: ");

   i = 0;

   do

   {

       fflush(stdin);

       c = getchar();

       string[i++] = c;

 

   } while (c != '\n');

   string[i - 1] = '\0';

   printf("The string entered is: %s\n", string);

   for (i = 0; i < strlen(string); i++)

   {

       while (i < strlen(string) && string[i] != ' ' && isalnum(string[i]))

       {

           unit[j++] = string[i++];

       }

       if (j != 0)

       {

           unit[j] = '\0';

           count = update(s, unit, count);

           j = 0;

       }

   }

 

   printf("*****************\nWord\tFrequency\n*****************\n");

   for (i = 0; i < count; i++)

   {

       printf("%s\t   %d\n", s[i].word, s[i].freq);

       if (s[i].freq > 1)

       {

           num++;

       }

   }

   printf("The number of repeated words are %d.\n", num);

 

   return 0;

}

 

int update(struct detail s[], const char unit[], int count)

{

   int i;

 

   for (i = 0; i < count; i++)

   {

       if (strcmp(s[i].word, unit) == 0)

       {

           s[i].freq++;

 

           return count;

       }

   }

   /*If control reaches here, it means no match found in struct*/

   strcpy(s[count].word, unit);

   s[count].freq++;

 

   /*count represents the number of fields updated in array s*/

   return (count + 1);

}

4 0
3 years ago
The reading element punctuation relates to the ability to
Goshia [24]
The ability to pause
3 0
3 years ago
What is another name for a port on routers?
Natali5045456 [20]
Another name for port on routers is interface (port interface). The interface is defined with its physical position on the router and its IP address. Also other properties can be defined <span>such as the speed, maximum transmission unit (MTU), and the encapsulation type. 
</span>Defining the settings on the router is called configuration. 
6 0
3 years ago
Simplify to obtain a sum of products: (A+B)(C+B)(D?+B)(ACD?+E)
lilavasa [31]

Answer:

(ACD'+BE)

Explanation:

(A+B)(C+B)(D'+B)(ACD'+E)

Product of (A+B)(C+B)

(A+B)(C+B)=AC+AB+BC+B^2 = AC+B(A+C+B)=AC+B

Product of (D'+B)(ACD'+E) with AC+B

(AC+B)(D'+B)(ACD'+E)

(AC+B)(D'+B)=ACD' + ACB +BD +B = ACD'+B(AC+D+1)=ACD'+B

Then we get:

(ACD'+B)(ACD'+E) = ACD'+ACD'E+ACD'B+BE

ACD'(1+E+B)+BE =ACD'+BE

7 0
3 years ago
Other questions:
  • Choose all statements that identify the benefits of programming design.
    10·2 answers
  • Technologies that function within the established system are called
    12·1 answer
  • If two hosts are connected by five networks, how many frames will there be when one host sends a packet to the other host? 1 2 5
    13·1 answer
  • Splunk knows where to break the event, where the time stamp is located and how to automatically create field value pairs using t
    7·1 answer
  • Insert a formula that references the appropriate worksheets in cell a3 on the offensive totals worksheet to calculate total pass
    15·1 answer
  • Many major employers routinely monitor the performance of their employees through the computers and telephones they use. Employe
    12·1 answer
  • Final one bit l y links are a virus that will corrupt your files do not go on it
    15·2 answers
  • ACTIVITY NO. 5 (DAY 5) FACT OR BLUFF. Write Fact if the statement is correct and write Bluff if it is incorrect.
    12·1 answer
  • The different languages that follow specific RULES. These languages use commands
    9·1 answer
  • Please answer fast computer picture above​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!