The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello there, I am having trouble completing these exercises from Starting Out With Python Third Edition:
Chapter 7 Exercise 6 Larger Than n
The a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the number in the list that are greater than number n.
Chapter 8 Exercise 6
Average Number of words
Write a program that reads the file's contents and calculates the average number of words per sentence.
Here is my code:
def main():
space = 0
infile = open('text.txt', 'r')
#Read data into a list.
sentence = infile.read()
#at the end of your function be sure to close the file
infile.close()
word = sentence.split(" ")
You can also download the text file.
for word in sentence:
word = len(word)
space = space + 1
print("The number of words in the sentence if", space, sep =" ")
main()
Chapter 9 Exercise 2
Capital Quiz
Write a program that creates a dictionary containing the U.S. States as key and their capitals as values. The program should then randomly quiz the user by displaying
the name of a state and asking the user to enter that state capital. the program should keep a count of the number of correct and incorrect responses.
Attachments:
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly