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
liberstina [14]
3 years ago
5

Python

Computers and Technology
1 answer:
xeze [42]3 years ago
3 0

Answer:

Following are the function to the Python Programming Language.

#define a function to read or crates the list

def GetUserValues():

 my_list=[]

 n=int(input("Enter range: "))

 for i in range(n):

   my_list.append(int(input(" :")))

 return my_list

#define a function to check the elements of the list

def IsListEven(mylist):

 #set the for loop

 for i in range(len(mylist)):

   #set if condition to check odd number

   if mylist[i]%2 !=0:

     #if condition is true retun false

     return False

 #otherwise return true

 return True

#define a function to check the elements of the list

def IsListOdd(mylist):

 #set the for loop

 for i in range(len(mylist)):

   #set if condition to check even number

   if mylist[i]%2==0:

     #if condition is true retun false

     return False

 #otherwise return true

 return True

#set variable to store list

l=GetUserValues()

#set if condition to check the function is true

if IsListOdd(l)==True:

 #then, print the message

 print("all odd")

#set elif condition to check the function is true

elif IsListEven(l)==True:

 #then, print the message

 print("all Even")

else:

 #otherwise print message.

 print("not even or odd")

<u>Output:</u>

Enter range: 5

:2

:4

:6

:8

:10

all Even

Explanation:

Here, we define a function "GetUserValues()" and inside the function.

  • Set the list data type variable "my_list" then, get input from the user in the variable "n".
  • Set the for loop which starts from 0 and end at the variable "n" then, get input from the user and appends inputs in the variable "my_list".
  • Then, we return list and close the function.

Then, we set a function "IsListEven()" and pass an argument "mylist" to check the elements is even or not, if the list elements is even then, return true otherwise, return false.

Then, we set a function "IsListOdd()" and pass an argument "mylist" to check the elements is odd or not, if the list elements is odd then, return true otherwise, return false.

Finally, we call and store the function in the variable "l" then, set conditions to check the list is even print "all even", if the is odd "all odd" otherwise, print "not even or odd".

You might be interested in
with the _______ network topology, reliability is the major advantage while high cost is the disadvantage.
Nady [450]
It's what the chat says, Its hybrid
6 0
3 years ago
Read 2 more answers
Mention how to install antivirus software in your computer, either by following the instructions given on installation CDs or we
Tema [17]

Answer:

ionow please help me

Explanation:

5 0
3 years ago
Using Python I need to Prompt the user to enter in a numerical score for a Math Class. The numerical score should be between 0 a
yaroslaw [1]

Answer:

<em>The program doesn't use comments; See explanation section for detailed line by line explanation</em>

<em>Program starts here</em>

def lettergrade(subject,score):

     print(subject+": "+str(score))

     if score >= 90 and score <= 100:

           print("Letter Grade: A")

     elif score >= 80 and score <= 89:

           print("Letter Grade: B")

     elif score >= 70 and score <= 79:

           print("Letter Grade: C")

     elif score >= 60 and score <= 69:

           print("Letter Grade: D")

     elif score >= 0 and score <= 59:

           print("Letter Grade: F")

     else:

           print("Invalid Score")

maths = int(input("Maths Score: "))

english = int(input("English Score: "))

pe = int(input("PE Score: "))

science = int(input("Science Score: "))

arts = int(input("Arts Score: "))

lettergrade("Maths Class: ",maths)

lettergrade("English Class: ",english)

lettergrade("PE Class: ",pe)

lettergrade("Science Class: ",science)

lettergrade("Arts Class: ",arts)

Explanation:

The program makes the following assumptions:

Scores between 90–100 has letter grade A

Scores between 80–89 has letter grade B

Scores between 70–79 has letter grade C

Scores between 60–69 has letter grade D

Scores between 0–69 has letter grade E

<em>Line by Line explanation</em>

This line defines the lettergrade functions; with two parameters (One for subject or class and the other for the score)

def lettergrade(subject,score):

This line prints the the score obtained by the student in a class (e.g. Maths Class)

     print(subject+": "+str(score))

The italicized determines the letter grade using if conditional statement

<em>This checks if score is between 90 and 100 (inclusive); if yes, letter grade A is printed</em>

<em>      if score >= 90 and score <= 100:</em>

<em>            print("Letter Grade: A")</em>

<em />

<em>This checks if score is between 80 and 89 (inclusive); if yes, letter grade B is printed</em>

<em>      elif score >= 80 and score <= 89:</em>

<em>            print("Letter Grade: B")</em>

<em />

<em>This checks if score is between 70 and 79 (inclusive); if yes, letter grade C is printed</em>

<em>      elif score >= 70 and score <= 79:</em>

<em>            print("Letter Grade: C")</em>

<em />

<em>This checks if score is between 60 and 69 (inclusive); if yes, letter grade D is printed</em>

<em>      elif score >= 60 and score <= 69:</em>

<em>            print("Letter Grade: D")</em>

<em />

<em>This checks if score is between 0 and 59 (inclusive); if yes, letter grade F is printed</em>

<em>      elif score >= 0 and score <= 59:</em>

<em>            print("Letter Grade: F")</em>

<em />

<em>If input score is less than 0 or greater than 100, "Invalid Score" is printed</em>

<em>      else:</em>

<em>            print("Invalid Score")</em>

This line prompts the user for score in Maths class

maths = int(input("Maths Score: "))

This line prompts the user for score in English class

english = int(input("English Score: "))

This line prompts the user for score in PE class

pe = int(input("PE Score: "))

This line prompts the user for score in Science class

science = int(input("Science Score: "))

This line prompts the user for score in Arts class

arts = int(input("Arts Score: "))

The next five statements is used to call the letter grade function for each class

lettergrade("Maths Class: ",maths)

lettergrade("English Class: ",english)

lettergrade("PE Class: ",pe)

lettergrade("Science Class: ",science)

lettergrade("Arts Class: ",arts)

7 0
2 years ago
Which of the following statements is true of a time management plan? It is work in progress that need to be altered many times?
marusya05 [52]
Cake cake cake cake
3 0
3 years ago
Identify a true statement about decision support systems (DSSs).
Zolol [24]

Answer:

a. facilitate improvements but do not necessarily cause them.

Explanation:

Decision Support Systems are interactive Information systems that assist  decision makers in coming up with strategies that help the organisation achieve its goals .The model base of the DSS uses mathematical and statistical models to analyse information then it generates reports and suggest possible solutions that can be implemented .The system is capable of giving a specific solution and some even allow the decision makers to give input before suggesting the most applicable solution.The effectiveness of a DSS is equally as important as its efficiency .The DSS unlike the conventional decision-making process should be able to analyse information effectively and come up with solutions in the shortest possible time frame.

7 0
3 years ago
Other questions:
  • What information should be included in the closing paragraph of a thank-you letter? a. Mention skills that were omitted during t
    6·2 answers
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • A distortion of information about the demand for a product as it passes from one entity to the next across the supply chain is c
    10·1 answer
  • What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
    10·2 answers
  • Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.
    9·1 answer
  • In order to preview an attachment in an e-mail, click the attachment in the ______
    8·1 answer
  • How many passes will it take to find the four in this list?
    15·2 answers
  • Use the drop-down menus to complete statements about audio file formats.
    10·1 answer
  • Digital communication and production chapter 17
    6·1 answer
  • What is output by the following code?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!