Question

Having some trouble with this python question. An answer would be greatly appreciated! minimum = 5...

Having some trouble with this python question. An answer would be greatly appreciated!

minimum = 5
maximum = 14
even = True

#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.
#
#Write a loop (we suggest a for loop) that prints the numbers
#from minimum to maximum, including minimum and maximum
#themselves. If even is True, print only the even numbers.
#If even is False, print only the odd numbers. You may assume
#minimum will always be less than maximum.
#
#With the initial values for minimum, maximum, and even above,
#this should print 6, 8, 10, 12, 14 -- each number would be on
#its own line, no commas.


#Add your code here!


0 0
Add a comment Improve this question Transcribed image text
Answer #1
minimum = 5
maximum = 14
even = True

# You may modify the lines of code above, but don't move them!
# When you Submit your code, we'll change these lines to
# assign different values to the variables.
#
# Write a loop (we suggest a for loop) that prints the numbers
# from minimum to maximum, including minimum and maximum
# themselves. If even is True, print only the even numbers.
# If even is False, print only the odd numbers. You may assume
# minimum will always be less than maximum.
#
# With the initial values for minimum, maximum, and even above,
# this should print 6, 8, 10, 12, 14 -- each number would be on
# its own line, no commas.


# Add your code here!
for i in range(minimum, maximum+1):
    if i % 2 == 0:
        if even:
            print(i)
    else:
        if not even:
            print(i)

Add a comment
Know the answer?
Add Answer to:
Having some trouble with this python question. An answer would be greatly appreciated! minimum = 5...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello; I would greatly appreciate your help with providing a solution to a problem that I'm...

    Hello; I would greatly appreciate your help with providing a solution to a problem that I'm having trouble with. Thank you! Write a program that reads a set of integers and then finds and prints the sum of the even and odd integers. The numbers will be read in from the user via the cin statement. You do not know how many numbers the user may enter. When the user enters a 0 (zero), then the user is done entering...

  • PLEASE DO BOTH OF THESE IN PYTHON!!! AND MAKE SURE THAT I CAN COPY THE CODE....

    PLEASE DO BOTH OF THESE IN PYTHON!!! AND MAKE SURE THAT I CAN COPY THE CODE. 1.) Exercise #1: Design and implement a program (name it PrintSum) that prompts the user for an integer values between 1 and 100. The program then uses a while loop to determine and print out the sum of all values between 1 and the entered value. The program rejects invalid input values with proper message such “Invalid Input. Try again.” Document your code and...

  • Create a new program in Mu and save it as ps3.3.1.py and take the code below...

    Create a new program in Mu and save it as ps3.3.1.py and take the code below and fix it as indicated in the comments: mystery_int = 50 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Write a for loop that prints every third number from 1 to # mystery_int inclusive (meaning that if mystery_int is 7, it #...

  • *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code...

    *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...

  • This needs to be in python, however, I am having trouble with the code. Is there...

    This needs to be in python, however, I am having trouble with the code. Is there any way to use the code that I already have under the main method? If so, what would be the rest of the code to finish it? #Create main method def main(): #Create empty list list=[] #Display to screen print("Please enter a 3 x 4 array:") #Create loop for rows and have each entered number added to list for i in range(3): list.append([int(x) for...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • Python Help Create a program that outputs a table from 1 to 5 using what you've...

    Python Help Create a program that outputs a table from 1 to 5 using what you've learned about "for" loops. Your program will print the number and indicate if the number is odd or even. If it is not odd you will multiply 2 numbers with it: number 1 and number 2. Your program must do the multiplication for only even numbers in the table. The output of your program should look like the figure below. Hint: Create a program...

  • please answer all, it would be greatly appreciated In this activity we practice the 8-step process...

    please answer all, it would be greatly appreciated In this activity we practice the 8-step process for curve sketching from Stewart's Calculus book. A. Domain E. Intervals of increase or decrease B. Intercepts F. Local maximum and minimum values C. Symmetry G. Concavity and points of inflection D. Asymptotes H. Sketch the curve Follow the process, make your sketch, and only then use a graphing program to check your work. 3. Let h(x) = x"e-*. Here, n is a positive...

  • Create a new program in Mu and save it as ps3.2.2.py and take the code below...

    Create a new program in Mu and save it as ps3.2.2.py and take the code below and fix it as indicated in the comments: egg = True milk = True butter = True flour = True # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Imagine you're deciding what you want to cook. The boolean # variables...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT