Part 1:
Read 2 numbers from the user. One small number and one big number for the range.
Use this in a for loop with range (for x in range(small, big))
Add all the numbers in this range and store in a variable called total.
Print total.
Part 2:
Make a list of colors called COLORS. Have at least 10 colors.
Read one color from the user in a variable called color.
Now use a for loop, and see if the color the user enters is there in your list.
If it is there, output that their color is found, else, output color not found.
Part 3:
Now go through the list of colors and print all the colors that have 3 letters or less.
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.
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.
Part 1: Read 2 numbers from the user. One small number and one big number for...
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 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 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 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 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 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 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...
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...
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...
# DISCUSSION SECTION WORK: # # 1. STUDENTS: download this file, ds4.py, and wordsMany.txt, from # http://www.cs.uiowa.edu/~cremer/courses/cs1210/etc/ds4/ # Save both in the same folder. # # 2. TA (aloud) and STUDENTS: Read the comments from START HERE! (just after these instructions) # to definition of anagramInfo function. Discuss any questions about what the functions should do. # # 3. TA demonstrate running anagramInfo("wordsMany.txt") on this unchanged file, to # see that it behaves reasonably despite having incomplete anagram-testing functions. #...