Reference no: EM132173768
Using python 3.
1)Suppose a program that uses command line arguments starts with the following line: import sys . Write the Python statement that will print the number of arguments that were provided on the command line.
2}Suppose the user intends to run the program by supplying command-line arguments , where an operation is supplied (capitalize, lowercase, count) followed by any number of strings. capitalize: changes all letters in the word to uppercase, lowercase: changes all letters in the word to lowercase,count: returns a count of all of the letters in the strings. Write a program that 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 myProg.py count This WAS, easy! as Pie. output would be 16
or
python myProg.py lower This WAS easy as Pie output would be " Invalid operation"
3)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.
Example1: python calcAvg.py 5 100 90 70 80 90
Output of the code should be: Average: 87
Example2: 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)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.