Site icon Tutor Bin

University of North Texas C++ Coding Python Code Project

University of North Texas C++ Coding Python Code Project

Description

General information/requirements/grading rules

  1. Adhere to the naming conventions discussed in class for variable names, program name and function names
  2. Use meaningful names for variables
  3. If there are two words in the variable use first word lowercase and first letter of second wordupper case i.e., firstName or underscore between 2 words i.e first_name
  4. Include appropriate comments in the code
  5. Output should be displayed exactly as mentioned against each problem
  6. Indent the lines of code appropriately

7. All programs must be written with the main module.

1. Write and read file

a ) write_num.py

Create a num_list file to write a range of numbers from 1 through 101.

Hints:

Define main ():

Open a file named as num_list in write mode.

Use for loop to write a range of numbers from 1 through 101 into the file.

Close file

End main()

b)read_num.py (10 points)

Use num_list file which got created in number 1.a. Write a program that will prompt the user to enter the name of the file (i.e. num_list.text), and display the first 10 lines of the file’s content.

Hints:

Define main ():

Declare variables: line and counter, and initialize them

Prompt for file name: use input function

Open the file in read mode.

Read the lines in the file with readline function: ‘inline.readline()’ and initialize counter to 1

Use a while loop to read and display the first 10 lines

Use rstrip method to remove n characters at the end of the line

Print the line

Update the counter when the line is read

Close file

End main()

Expected output:

Enter the name of the file: filename.txt

#

#

#

#

#

#

#

#

2. numanalysis.py

Write a program that asks user to enter a series of 10 numbers. The program should store the numbers in a list then display the following data.

1. The lowest number in the list

2. The highest number in the list

3. The total of the number in the list

4. The average of the number in the list

Hints:

Define main ():

Declare variables and initialize them

Create an empty list

Use the for loop with the range function to loop through 10 numbers.

Prompt the User to enter the numbers from 1- 10.

Ex: Enter number 1 of 10:

Use append function to populate the list

Use min, max, sum, functions to find the low , high and total number of the list.

Ex: low = min(number_list)

Print Low, high , total and average numbers of the list.

End main()

Expected output :

Low: #.##
High: #.##
Total: #.##
Average: #.##

3. char_analysis.py

Write a program that reads the file’s contents and determine the following:

  1. The number of Uppercase letters in the file
  2. The number of Lowercase letters in the file
  3. The number of digits in the file
  4. The number of whitespace characters in the file

HINTS:

Define main():

Declare Local variables

Open file text.txt for reading. Use ‘text.txt’ file attached under module.

User for loop to step through each character in the file.

Determine if the character is uppercase, lowercase, a digit, or space, and keep a running total of each.

Close the file.

Display the totals of uppercase, lowercase, digits, spaces.

Sample Output:

Uppercase letters: 29
Lowercase letters: 1228
Digits: 30

Spaces: 260

4. unique.py Write a program that opens a specified text file (text2) then display a list of all unique words found in the file .

HINTS:

Define main():

Declare Local variables

Open file text2.txt for reading. Use ‘text2.txt’ file attached under module.

User the set method to find the unique words in the file and store each of them as an element of the set.

Close the file.

Sample output:

These are the unique words in the text:
its
mail-carrying
in
So
name
English
Russia,
twelve
metric
Java,
is
were
1,162
speed
shipowner

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Exit mobile version