using python Suppose the user is expected to supply words on

using python

Suppose the user is expected to supply words on the command line as shown below:
Example: python myProg.py hello there
Output of the code should be:   
Average word length: 5 Number of Vowels: 4
Write Python code to correctly produce the output shown.

Lab 7: Command Line Arguments Suppose a program that uses command line arguments starts with the following line: import s Write the Python statement that will print the number of arguments that were provided on the command line Suppose the user intends to run the program by supplying command-line arguments, where a operation is supplied (capitalize lowercase count followed by any number of strings. capitalize changes etters in the word to uppercase, lowercase: changes all letters in the word to lowercase, count: returns a count of a of the letters in the strings. Write a program at processes the command line arguments correctly Examples: python myProg.py capitalize This is easy output would be THIS IS EASY Or python myProg.py lowercase This WAS easy as Pie output would be this was easy as pie Or python my Prog.py count This WAS, easy! as Pie. output would be 16 Or python my Prog.py lower This WAS easy as Pie output would be Invalid operation\" Write a Python program that accepts the number of scores followed by that many scores via the command line and prints the average of the scores. Include appropriate error-checking to make sure command line arguments are provided. No other error checking is required Example: python calcAvg.py 5 100 90 70 80 90 Output of the code should be Average: 87 Example 2: python calcAvg.py 3 100 90 80 output of the code should be: Average: 90 Example 3: python calcAvg.py Output of the code should be No scores were provided average cannot be calculated. 4. There are errors in the code shown. List and describe each error, and provide a correction import sys if len(argv) 3: name FargVIU scores arg for ct in range (len (scores)): scores[ctl 10 print (scores) else print (\"invalid of arguments\")

Solution

3)

import argparse

parser = argparse.ArgumentParser(description=\'Integer processing\')
parser.add_argument(\'integers\', metavar=\'N\', type=int, nargs=\'+\',
help=\'an integers to get average\')
parser.add_argument(\'--average:\', dest=\'accumulate\', action=\'store_const\',
const=sum)

args = parser.parse_args()
print((args.accumulate(args.integers))/nargs)

4) Range at Scores variable is exceding so it raises an error.

To correct it just write as Scores = argv[1:]

using python Suppose the user is expected to supply words on the command line as shown below: Example: python myProg.py hello there Output of the code should be

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site