For Python I need to take this step by step I need help with the following: both
ID: 3825403 • Letter: F
Question
For Python I need to take this step by step
I need help with the following:
both files have been created
Step one Start a new file named test.py
Write the code to create a function that would ask the user to enter a phrase, place these lines one at a time into a list. Create a loop to go through the array and pace each element one at a time into a file named outFile.txt. Write another loop that will print that file one line at a time to the console. Make sure to close the file. Call and test the function.
Using bibfile.txt write a function that would read the first ten lines, place them into a file named firstBib.txt. Write the next ten lines into another file named secondBib.txt. Call and test the function.
Second step on test.py file
Write the code to make a function that would create a tuple with the numbers one through 10. Convert this to a list and append 11 to the list Extra Credit insert the number 75 in the 5th element. Call and test the function.
Third step on test.py file
Write the code to create a function that will make a dictionary where each month of the year has their own key. Use a loop to write the key value pairs to the console. Call and test the function.
Fouth step create grade.py
Open a new file named grade.py. Create a class named ask. Have this class when called print the words “This is an easy A”. Go back to the test.py file and write a function that when called will instantiate a member of the ask class then call the method to have the object print the phrase.
This I am having trouble with please help asap
Explanation / Answer
while True:
try:
age = int(input("Please enter your age: "))
except ValueError:
print("Sorry, I didn't understand that.")
continue
if age < 0:
print("Sorry, your response must not be negative.")
continue
else:
#age was successfully parsed, and we're happy with its value.
#we're ready to exit the loop.
break
if age >= 25:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.