Program 3 Directions Names.txtJoseph smitheLiza roxcY SnowJo…
Program 3 Directions Names.txtJoseph smitheLiza roxcY SnowJoseph FIelding SmithEmMa HalE Smithjoseph Fielding SmIthDavid OMAN McKayLIndA KjaR burToN Write a program that opens the above file, Names.txt, for reading, and writes an alphabetized list of the names to a new file, alpha_names.txt. Above, we show several lines of Names.txt, but in practice, the file may be much longer. All names in the output file should be uppercase. Make sure you read from input and output files as specified on the command line. Complete this program, Exam 2 Part 2: Question 3, on CodeBuddy. Here is an example of the correct output for the file above (again, any case—upper, lower, or mixed—is correct): alpha_names.txtDAVID OMAN MCKAYELIZA ROXCY SNOWEMMA HALE SMITHJOSEPH FIELDING SMITHJOSEPH FIELDING SMITHJOSEPH SMITHLINDA KJAR BURTON We will execute your code with the following command (or something similar): python studentcode.py Names.txt alpha_names.txt As always, make sure to use system arguments to get the file names or your program will fail.
Read DetailsProgram 1 Directions One of the first built-in functions in…
Program 1 Directions One of the first built-in functions in Python we learned about was len(), and it is one of the most commonly used functions in Python. For this question, you will write a program that calculates the length of a string from the command line. The user may enter an empty string (length of 0) and the user may also choose to enter only whitespace (tabs and spaces, and these are valid characters that must be counted). Once you have the length, print a message to the screen (see below for specific message text) that includes the length of the text. You may not use the len() function, or the word len, anywhere in your program or you will receive no credit for the question (this restriction applies only to this question). We recommend using a for loop for this question since a while loop is substantially more difficult to accomplish this specific task, but you may choose. Complete this program, Exam 2 Part 2: Question 1, on CodeBuddy. The following code is included at the top of your program: import sys seq1 = sys.argv[1] Following are some examples of what is printed to the screen when I run my program (information the user types is highlighted). Example 1 (a mix of characters) If I execute the following command: python studentcode.py “AghfgTc # CG!T” Your program should match the output exactly: The string you entered is 14 characters long Example 2 (an empty string) If I execute the following command (remember, the quotation marks are not actually part of the string): python studentcode.py “” Your program should match the output exactly: The string you entered is 0 characters long Example 3 (6 whitespace characters only) If I execute the following command: python studentcode.py “ ” Your program should match the output exactly: The string you entered is 6 characters long
Read Details