Question

Part 1: Read 2 numbers from the user. One small number and one big number for...

  1. Part 1:

    1. Read 2 numbers from the user. One small number and one big number for the range.

    2. Use this in a for loop with range (for x in range(small, big))

    3. Add all the numbers in this range and store in a variable called total.

    4. Print total.

  2. Part 2:

    1. Make a list of colors called COLORS. Have at least 10 colors.

    2. Read one color from the user in a variable called color.

    3. Now use a for loop, and see if the color the user enters is there in your list.

    4. If it is there, output that their color is found, else, output color not found.

  3. Part 3:

    1. Now go through the list of colors and print all the colors that have 3 letters or less.

    2. Go through the list of colors and print all the colors that have 5 letters or more.

References:

Refer to this pdf file (link here) or refer here for more tutorials.

  • Section 1.13.2 The list Type

  • Section 1.13.3 The range Function, Part 1 from the pdf file

  • Section 1.13 Loops and Sequences from the pdf file.

My powerpoints in this module.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

All code is in python 3.

Part 1 :

small = input ("Enter small number :")
big = input ("Enter big number :" )
total=0

for i in range(int(small), int(big)):
total+=i
print(" total sum between given range : ", total)

PART 2:

list = ["red", "black", "blue","greeen","purple","pink","brown","gold","orange","yellow"]   
color =input("Enter your color name in small letter ")
flag=0
for i in range(len(list)):
if(list[i]==color):
flag=1
if(flag==1):
print( end=" "+"color is found ")
else:
print( "color is not found ")

PART 3: // take care of indented

list = ["red", "black", "blue","greeen","purple","pink","brown","gold","orange","yellow"]   
print("printing the list of color whose length is less than or equasl to three: ")
for i in range(len(list)):
if(len(list[i])<=3):
print(list[i])
print(end=" "+"printing the color whose word length is five or more than five: ")
for i in range(len(list)):
if(len(list[i])>=5):
print(list[i])

sample output:

Thanks.

Add a comment
Know the answer?
Add Answer to:
Part 1: Read 2 numbers from the user. One small number and one big number for...
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
  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

  • (1) Read in a number from the user that is in the ranger 1-200. If the...

    (1) Read in a number from the user that is in the ranger 1-200. If the user inputs a number out of that range, print out:Invalid number, try again. and read in a number until a valid one is produced. (2) Print out the numbers from 1 to userInput but: If a number is divisible by 3, print Fizz instead If a number is divisible by 5, print Buzz instead If a number is divisible by both 3 and 5,...

  • This program is in C++ Write a program that validates charge account numbers read in from...

    This program is in C++ Write a program that validates charge account numbers read in from the file Charges.txt following this assignment (A23 Data). Use a selection sort function on the array to sort the numbers then use a binary search to validate the account numbers. Print out the sorted list of account numbers so you can see the valid ones. Prompt the user to enter an account number and the validate that number. If the account number entered is...

  • Ask the user for the name of a file. Read a list of numbers of unknown...

    Ask the user for the name of a file. Read a list of numbers of unknown length from the file. Find and print the MEDIAN and the MODE(S) of the set of numbers. Do not use python statistics functions to find the medium or mode To find the MODE(S) Create a dictionary using the numbers as the keys, and the values are how often that number appears in the list. For instance, with this list [1,1,5], the dictionary would be...

  • LANGUAGE = C i. Write a program that takes int numbers from user until user gives...

    LANGUAGE = C i. Write a program that takes int numbers from user until user gives a sentinel value (loop terminating condition). Sort the numbers in ascending order using Insertion sort method. Sorting part should be done in different function named insertionSort(). Your code should count the number of swaps required to sort the numbers. Print the sorted list and total number of swaps that was required to sort those numbers. (4 marks) ii. In this part take another number...

  • JAVA please! Prime numbers are interesting numbers. A prime number is one that is only divisible...

    JAVA please! Prime numbers are interesting numbers. A prime number is one that is only divisible by 1 and itself. For hundreds of years mathematicians have looked for the largest prime number. In the year 1456 the largest known prime was 8191. By the year 1588 it was a 6-digit number: 131,071. The famous mathematician Leonhard Euler discovered the 10-digit number 2,147,483,647 in 1772. Over the years larger and larger primes have been found. There are contests to find the...

  • Description: Create a program called numstat.py that reads a series of integer numbers from a file...

    Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • LAB 4: JavaScript Loops Part I) 1) Make an array of colors, instead of responses, call...

    LAB 4: JavaScript Loops Part I) 1) Make an array of colors, instead of responses, call it colors. Color names go inside quotes, i.e. "red". 2) Copy the line of the var randomNum, but instead of looking at the length of responses, look at the length of your colors array. 3) Declare a variable myColor below the randomNum variable declaration. 4) Save a randomly chosen color into the variable myColor.     colors[randomNum] picks a random color from the array. Save...

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

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
ADVERTISEMENT