Write a python program in any topic that contains:
1. at least one of the container types (list, tuple, set, or dictionary)
2. at least one iteration type (for, while)
3. at least one conditional
4. at least one user-defined function
5. at least one user-defined class (could be very simple)
6. file input or output
Specify where you used each part in the program.
# 5. at least one user-defined class
class MyClass:
# 1. at least one of the container types (list, tuple, set, or
dictionary)
numbers = []
def __initi__(self):
print("COnstructor")
# 4. at least one user-defined function
def addNumbers(self, number):
self.numbers.append(number)
# 2. at least one iteration type (for, while)
def printNumbers(self):
# 6. file input or output
f = open('data.txt', 'w')
for number in self.numbers:
# 3. at least one conditional
if number % 2 == 0:
print(number)
f.write(str(number) + "\n")
f.close()
obj = MyClass()
# 2. at least one iteration type (for, while)
for i in range(10):
obj.addNumbers(i)
obj.printNumbers()

Please check the code. If you have any doubts comment below and I am happy to help :)
Write a python program in any topic that contains: 1. at least one of the container...
Python 3.7 Coding assignment This Program should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time. Ask a user to enter the name of a text file....
Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/share/dict/words (if you machine does not have it, you can copy it from a Linux machine such as npu29). The minimum requirement is to check if each word in the file exists in the dictionary as is (case insensitive). Your spell checker should inlcude at least two features: 1. Check the simple plural forms (add s or es). 2. Check the simple verb past...
INTRODUCTORY PYTHON QUESTION For my Intro to Python class, I need a very simple program that generates random sentences using a dictionary / list and the random.choice function. The program must ask user how many sentences they want generated. The dictionary can look like this, just not sure where to go from here: words = [["The", "A"], ["young", "energetic", "happy", "small", "cute"], ["boy", "dog", "cat", "girl", "student", "child"], ["ate the homework.", "played with the ball.", "jumped on the desk.", "ate...
Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...
Python Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. How to format each item of your inverted dictionary as a text string in the output file. Create an input file with your original...
Questions 1. How to create a comment in python? 2. The way to obtain user input from command line 3. List standard mathematical operators in python and explain them 4. List comparison operators in python 5. Explain while loop. Give example 6. Explain for loop. Give example 7. How to create infinite loop? And how to stop it? 8. Explain a built-in function ‘range’ for ‘for’ loop 9. Explain break statement 10. Explain continue statement 11. Explain pass statement 12....
Write Java program: • Is at least 8 characters long • Contains at least 1 lower letter character • Contains at least 1 upper letter character • Contains at least 1 numeric digit • Contains at least 1 special character from the set: !@#$%^&* • Does not contain the word “and” or the word “the” Prompts the user for a password, including the requirements above in your output. Output a string that states valid or invalid. If invalid, state which...
In this lab you will write a spell check program. The program has two input files: one is the dictionary (a list of valid words) and the other is the document to be spellchecked. The program will read in the words for the dictionary, then will read the document and check whether each word is found in the dictionary. If not, the user will be prompted to leave the word as is or type in a replacement word and add...
Simple Python Program Working with strings Write a Python program to read in a number of strings from the user. Stop when the user enters “Done”. Then check if each of the strings contains all the letters of the alphabet. Print the results in the form of a dictionary, where they keys are the strings and the values are the Truth Value for the string, which you just calculated. Sample Run: Enter the strings: taco cat The quick brown fox...
Write a perl program Use a while loop to get user input until the user enters "quit" Use a regex to replace any occurrence of the word "python" with the word "perl" and print out the updated version Provide the perl program (.pl file) as well as a screenshot of the output (show at least one example with python being replaced)