Question

[Python] what are the program solutions to the promts? Write a program to determine which word...

[Python] what are the program solutions to the promts?

Write a program to determine which word is the shortest of the following: apple, banana, peach, plum, grapefruit.

Write a program to determine the average number given in a list. The first line of your program should give a name to a list to be averaged: e.g numbers = [3,17,1,44,239]

Homework Answers

Answer #1

words=["apple","banana","peach","plum","grapefruit"]
length=len(words[0])
indx=0
for i in range(len(words)):
if len(words[i])<length:
length=len(words[i])
indx=i
  
print("Shortest word is:",words[indx])

numbers = [3,17,1,44,239]
sum=0
for i in range(len(numbers)):
sum=sum+numbers[i];

length=len(numbers)
avg=sum/length

print("Average of list is: ",avg)

Know the answer?
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
Similar Questions
python program 1. create a .txt file and call it fruits.txt, add the following items to...
python program 1. create a .txt file and call it fruits.txt, add the following items to the file Apple Banana Peach Strawberry Watermelon Kiwi Grape 2. Write a program that does the following: - Reads the fruit.txt - Converts the contents into all uppercase - Writes the uppercased values into a text file called "UpperFruit.txt" OUTPUT SHOULD BE: APPLE BANANA PEACH STRAWBERRY WATERMELON KIWI GRAPE
How to code this in python Write a program that computes and prints the first 1000...
How to code this in python Write a program that computes and prints the first 1000 prime numbers - simply write out each prime number on a new line. In implementing this solution I want you to define 2 functions: is_prime which can be used to test whether a number is a prime (e.g. is_prime(17) returns True but is_prime(9) returns False) and compute_primes which will return an array (or Python list) of the first n primes where n is passed...
PYTHON- write a program that accepts a param (num) that will determine how many numbers will...
PYTHON- write a program that accepts a param (num) that will determine how many numbers will be in the output. every number after the first is the product of the prev 2 numbers, we will always start with [5,2] . return output (list) example. the user will insert 6 as the num. we start with [5,2] and the output will be [5,2,10,20,200,4000]
Write a python program that will perform text analysis on an input text using all of...
Write a python program that will perform text analysis on an input text using all of the following steps: 1. Take the name of an input file as a command line argument. For example, your program might be called using python3 freq.py example1 to direct you to process a plain text file called example. More information is given on how to do this below. 2. Read the contents of the file into your program and divide the text into a...
Write a python program that reads a word list and prints out all the anagrams in...
Write a python program that reads a word list and prints out all the anagrams in the word list. In earlier exercises you saw how to read a word list. Also, in earlier examples we saw how the sorted characters of a word are a useful canonical representation of an anagram (Hint: Therefore, useful as a key).
Write a python program to find the sum of the first n natural numbers, where the...
Write a python program to find the sum of the first n natural numbers, where the value of n is provided by the user. What is the sum of the first 200 numbers? Write a program that finds the average of a series of numbers entered by the user. As in the previous problem, the program will first ask the user how many numbers there are. Note: the average should always be a float. What is the average of 10.2,...
Write a program in python that prints the count of all prime numbers between A and...
Write a program in python that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = The 5 digit unique number you had picked at the beginning of the semester B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2,...
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...
IN PYTHON : Write a program that asks the user for a number. Write the number...
IN PYTHON : Write a program that asks the user for a number. Write the number to a file called total.txt. Then ask the user for a second number. Write the new number on line 2 with the total for both numbers next to it separated by a comma. Then ask the user for a third number and do the same. Keep asking for numbers until the person puts in a zero to terminate the program. Close the file. Be...
In Python write a program that prompts the user for six elements and their atomic numbers...
In Python write a program that prompts the user for six elements and their atomic numbers and stores them in a list. Each element and weight pair should also be a list. After the values have been entered, print the list as it entered. Then print the first two characters from the element names (the first character capitalized and the second in lower case) along with the atomic number, starting with the element with the lowest atomic number. You must...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT