Write a program that creates a file with a specific set of formatted values. o Ask the
Question:
● Write a program that creates a file with a specific set of formatted values. o Ask the user for the name of the file and create that file. o 20 lines of data will be written to the file with the following format: CCCCC III ccc FFFF.FF
Notes: CCCCC will be 5 uppercase letters, each of the 5 selected randomly. III is a random integer 0 and 999, right justified. ccc three lowercase letters, each selected randomly. FFFF.FF a random floating-point number between0 and 9999.99, limited to 2 decimal places. Each of the 4 values will be generated with a function, one function for each value. Example line in the text file: CPHEJ 1468 ksd 4356.82
# Python code to demonstrate the working of
# shuffle() and uniform() # importing "random" for random operations import random
# Initializing list li = [1, 4, 5, 10, 2]
# Printing list before shuffling print("The list before shuffling is : ", end="") for i in range(0, len(li)): print(li[i], end=" ") print("")
# using shuffle() to shuffle the list random.shuffle(li)
# Printing list after shuffling print("The list after shuffling is : ", end="") for i in range(0, len(li)): print(li[i], end=" ") print("")
# using uniform() to generate random floating number in range
# prints number between 5 and 16 print("The random floating point number between 5 and 10 is : ", end="") print(random.uniform(5, 10))
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill