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: | 304 Weeks Ago, 3 Days 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