Write a program named palindromefinder.py which takes two files as arguments. The first file is the input file which contains one word per line and the second file is the output file. The output file is created by finding and outputting all the palindromes in the input file. A palindrome is a sequence of characters which reads the same backwards and forwards. For example, the word 'racecar' is a palindrome because if you read it from left to right or right to left the word is the same. Let us further limit our definition of a palindrome to a sequence of characters greater than length 1. A sample input file is provided named words_shuffled. The file contains 235,885 words. You may want to create smaller sample input files before attempting to tackle the 235,885 word sample file. Your program should not take longer than 5 seconds to calculate the output
In Python 3,
MY CODE: palindromefinder.py
import sys
def is_Palindrome(s):
if len(s) > 1 and s == s[::-1]:
return true
else:
return false
def main():
if len(sys.argv) < 2:
print('Not enough arguments. Please provide a file')
exit(1)
file_name = sys.argv[1]
list_of_palindrome = []
with open(file_name, 'r') as file_handle:
for line in file_handle:
lowercase_string = string.lower()
if is_Palindrome(lowercase_string):
list_of_palindrome.append(string)
else:
print(list_of_palindrome)
If you can adjust my code to get program running that would be ideal, but if you need to start from scratch that is fine.

Answers

Answer 1

Open your python-3 console and import the following .py file

#necessary to import file

import sys

#define function

def palindrome(s):

   return len(s) > 1 and s == s[::-1]

def main():

   if len(sys.argv) < 3:

       print('Problem reading the file')

       exit(1)

   file_input = sys.argv[1]

   file_output = sys.argv[2]

   try:

       with open(file_input, 'r') as file open(file_output, 'w') as w:

           for raw in file:

               raw = raw.strip()

               #call function

               if palindrome(raw.lower()):

                   w.write(raw + "\n")

   except IOError:

       print("error with ", file_input)

if __name__ == '__main__':

   main()


Related Questions

PLEASE HURRY!!!

Look at the image below!

Answers

Answer:A and E

Explanation:

The last three are strings while the other choices are integers.

Putting ' ' or " " around something makes it a string and the input is asking the user to input a string.

Adding a rock or stone looking characteristic to a background is which element of design?

Answers

Answer:

Explanation:

ejhdkl;xs

'

QUESTION : John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows his to access documents and software while on the move?
!!MUTI ANSWER QUESTION BTW!!
A.cloud computing
B.grid computing
C.mobile computing
D.green computing
E.virtualization

Answers

Answer:

mobile computing

Explanation:

Select the action that a database does not perform.


Sort and manipulate the data.

Find the average of four numbers.

Update information in more than one place at the same time.

Create data entry forms.

Answers

create data entry forms

Answer:

the answer is B. find the average of four numbers

Explanation:

What is one way to calm your feelings before taking
a test?

Answers

Answer:

For me I chew gum if avaliable and if it's not I think of something funny

Explanation:

The following are basic word processing functions that all students should be able to utilize in their work, EXCEPT:

Group of answer choices

A.) Spell check

B.) Convert to PDF

C.) Printing

D.) References

Answers

I would say B or D but preferably B

The trigonometry book says: sin^2(t) + cos^2(t) = 1 Write a Python program that verifies the formula with the help of the Python Math module. Note that the trigonometric functions in the module act on the angles in radians. Your program should perform the following steps 3 times: 1. Pick a random number between 0 and 180 degrees representing an angle in degrees, say Dangle 2. Convert the angle from degrees to radians, say Rangle 3. Use the Math module to find and print the values of sin(Rangle) and cos(Rangle), and 4. Compute and print the value of the above expression: sin^2(Rangle) + cos^2(Rangle). You can then visually verify if the result printed is 1 (or close to it).

Answers

Answer:

If you open your python-3 console and execute the following .py code you will have the following output. (Inputing 20 e.g)

Write the angles in degrees: 20

radian angles is:  0.3490658503988659

cosene( 0.3490658503988659 ) =  0.9396926207859084

sine( 0.3490658503988659 ) =  0.3420201433256687

sin^2( 0.3490658503988659 ) + cos^2( 0.3490658503988659 ) =  1.0

Explanation:

Code

import math

for i in range(1,4):

   angle = int(input('Write the angles in degrees: '))

   #mat library better works with radians

   angle_radians = (angle*math.pi)/180

   #print output

   print('radian angles is: ',angle_radians)

   print('cosene(',angle_radians,') = ',math.cos(angle_radians))

   print('sine(',angle_radians,') = ',math.sin(angle_radians))

   res = (math.sin(angle_radians))**2 + (math.cos(angle_radians))**2

   print('sin^2(',angle_radians,') + cos^2(',angle_radians,') = ',res)

Write the SQL queries that accomplish the following tasks in the HAFH Realty Company Property Management Database:

Answers

The complete question is:

Write the SQL queries that accomplish the following tasks in the HAFH Realty Company Property Management Database:

a. Display the SMemberID and SMemberName for all staff members.

b. Display the CCID, CCName, and CCIndustry for all corporate clients.

c. Display the BuildingID, BNoOfFloors, and the manager’s MFName and MLName for all buildings.

d. Display the MFName, MLName, MSalary, MBDate, and number of buildings that the manager manages for all managers with a salary less than $55,000.

e. Display the BuildingID and AptNo, for all apartments leased by the corporate client WindyCT.

f. Display the InsID and InsName for all inspectors whose next inspection is scheduled after 1-JAN-2014. Do not display the same information more than once.

g. Display the SMemberID and SMemberName of staff members cleaning apartments rented by corporate clients whose corporate location is Chicago. Do not display the same information more than once.

h. Display the CCName of the client and the CCName of the client who referred it, for every client referred by a client in the music industry.

i. Display the BuildingID, AptNo, and ANoOfBedrooms for all apartments that are not leased.

Also a schema of the HAFH database is attached.

Answer:

Using SQL's SELECT, FROM, WHERE syntax, find below the queries for each question.

a.

SELECT SMemberID , SMemberName  

FROM staffmember

b.

SELECT CCID, CCName, CCIndustry

FROM corpclient

c.

SELECT b.BuildingID, b.BNoOfFloors, m.MFName, m.MLName

FROM building b, manager m

WHERE b.ManagerID = m.ManagerID

d.  

SELECT m.MFName, m.MLName, m.MSalary, m.MBDate, count(*) as buildings

FROM building b, manager m

WHERE m.MSalary<55000

AND b.ManagerID = m.ManagerID

GROUP BY m.ManagerID

e.

SELECT b.BuildingID, a.AptNo

FROM building b, apartment a, corpclient c

WHERE c.CCName = "WindyCT"

AND c.CCID = a.CCID

AND a.BuildingID = b.BuildingID

f.

SELECT DISTINCT i.InsID, i.InsName  

FROM inspector i, inspecting x

WHERE i.InsID = x.InsID

AND x.DateNext > "2014-01-01"

g.

SELECT DISTINCT s.SMemberID, s.SMemberName  

FROM staffmember s, cleaning c, apartment a, corpclient cc

WHERE s.SmemberID = c.SmemberID

AND c.AptNo = a.AptNo

AND a.CCID = cc.CCID

AND cc.CCLocation = "Chicago"

h.

SELECT cc1.CCName, cc2.CCName  

FROM corpclient cc1, corpclient cc2

WHERE cc1.CCIDReferencedBy = cc2.CCID  

AND cc2.CCIndustry = "Music"

i.

SELECT a.BuildingID, a.AptNo, a.ANoOfBedrooms

FROM apartment a

WHERE a.CCID NOT IN (SELECT c.CCID FROM corpclient c)

What is troubleshooting?

creating a checklist
finding and fixing a problem
scanning for viruses
performing regular maintenance

Answers

Finding and fixing a problem
The answer is finding and fixing a problem.

What type of result does the MATCH function, when used on its own, return?

Answers

Answer:

It returns the lookup value located in a specific location.

Explanation:

You are given the program to support the management of a movie rental place
You are required to perform refactoring on that program to improve its quality. You are encouraged to use refactoring services in IDEs such as Eclipse or IntelliJ.
Then, you are required
1) to add a main() method to test the program; and
2) to add a new method to print the statement for a customer in XML format, e.g., John Smith , Independent Day , etc. Please submit your resulting code
Your solution must at least contain:
1. At least 3 method extraction operations
2. At least 3 creation of 3 new classes
3. At least 3 moving method operations
4. At least 3 renaming operations

Answers

Answer:

to add a main loop

Explanation:

Chris would like to adjust an image that he has inserted to give it an older look and feel.

What is the easiest way of doing this?

adjusting contrast and color
adjusting background
applying picture styles
adjusting the size and shape

Answers

Answer:

C- applying picture styles

Explanation: ;)

Answer:

applying picture styles

Explanation:

edge/canvas test review

How does multimedia content enhance a user’s Web browsing experience?

Answers

Answer:

hi

Explanation:

89

Answer:

I would say it is more engaging and helps the user remember the content better as multimedia is more memorable than just plain text. It can also display things that plain text is unable to, such as sounds and detailed pictures.

Explanation:

What is the most basic way to create a query?

Answers

Answer- are Navigation queries and keyword search queries.
Hope this helps:)

QUICK!!!

Which of the following occupations would work with oceanographers to better understand the relationship between the ocean and the
atmosphere?
1.research meteorologist
2. broadcast meteorologist
3. atmospheric scientist
4. forensic meteorologist

Answers

Answer:

I think the answer would be C. atmospheric scientist

sa kumbensiyon naihalal si andres bonofacio bilang​

Answers

Answer:

the contemporary Supremo (supreme leader) of the Katipunan

The IP address and the port are both numbers. Which statement is true?
A computer has many IP addresses and many ports.
A computer has one IP address and many ports.
A computer has one IP address and one port,
Acomputer has many IP addresses and one port.

Answers

Answer:

A computer has one IP address and many ports.

Explanation:

Answer:

A computer has one IP address and many ports.

Explanation:

Cleary specifying the theme to be used for a site
before building it provides which main advantage:
site navigation
site consistency
O
a clear message
O O O
improved readability

Answers

Answer: site consistency

Answer:

B) Site Consistency

Explanation:

PLEASE HURRY!!
Look at the image below!

Answers

The missing word is input. The input function asks the user to enter something and in this case, its asking for the user to enter the x-coordinate of the first point.

What issues will the Internet of Things present to Cybersecurity?

Answers

Answer:

The IoT offers new ways for businesses to create value, however the constant connectivity and data sharing also creates new opportunities for information to be compromised. Explore some of the more notable developments in the battle to combat cyber risks.

Explanation:

I hope this helps you. UwU. P.S. Plz mark me Brainlyest

list any five feature of drwing toolbar

Answers

Line, arrow, rectangle, ellipse, text, vertical text, curve, stars are all possible answers -hope this helped, have a good night!!

Answer:

The tools in this part of the Drawing toolbar are:

Select: selects objects. To select multiple objects click on the top leftmost object and while keeping the mouse button pressed, drag the mouse to the bottom rightmost object of the intended selection. A marching ants rectangle identifying the selection area is displayed. It is also possible to select several objects by pressing the Control button while selecting the individual objects.

Line: draws a straight line.

Arrow: draws a straight line ending with an arrowhead. The arrowhead will be placed where you release the mouse button.

Rectangle: draws a rectangle. Press the Shift button to draw a square.

Ellipse: draws an ellipse. Press the Shift button to draw a circle.

Text: creates a text box with text aligned horizontally.

Vertical text: creates a text box with text aligned vertically. This tool is available only when Asian language support has been enabled in Tools > Options > Language Settings > Languages.

Curve: draws a curve. Click the black triangle for more options, shown below. Note that the title of the submenu when undocked is Lines.

1 // Application contains a starting list of three products for sale2 // The user is prompted for additional items3 // After each new entry, the alphabetically sorted list is displayed4 import java.util.*;5 public class DebugNine36 {7 public static void main(String[] args)8 {9 ArrayListproducts = new ArrayList();10 products.add(shampoo);11 products.add(moisturizer);12 products.add(conditioner);13 Collections.sort(products);14 display(products);15 final String QUIT = "quit";16 String entry;17 Scanner input = new Scanner(System.in);18 System.out.print("\nEnter a product or " + QUIT + " to quit >> ");19 entry = input.nextLine();20 while(entry.equals("quit"))21 {22 products.add(entry);23 Collections.sort(products);24 display()25 System.out.print("\nEnter a product or " + QUIT + " to quit >> ");26 entry = input.nextLine();27 }28 public static void display(ArrayList products)29 {30 System.out.println("\nThe size of the list is " + products.size());31 for(int x = 0; x == products.size(); ++x)32 System.out.println(products.get(x));33 }34 }35//Debugging Exercises, Chapter 9;Java Programming, Joyce Farraell, 8th

Answers

Answer:

Here is the corrected code:

import java.util.*;

public class DebugNine36 {  //class name

  public static void main(String[] args)    {  //start of main method

     ArrayList<String>products = new ArrayList<String>();  //creates an ArrayList of type String names products

     products.add("shampoo");  //add shampoo to product array list

     products.add("moisturizer");  //add moisturizer product array list

     products.add("conditioner");  //add conditioner product array list

     Collections.sort(products);  //sort the elements in products array list

     display(products);  //calls display method by passing products array list

     final String QUIT = "quit";  //declares a variable to quit the program

     String entry;  //declares a variable to hold product/element or quit

     Scanner input = new Scanner(System.in);  //creates Scanner object

     System.out.print("\nEnter a product or " + QUIT + " to quit >> ");  //prompts user to enter a product or enter quit to exit

     entry = input.nextLine();  //reads the entry value from user

     while(!entry.equals("quit"))       {  //loops until user enters quit

        products.add(entry);  //adds entry (product) to products array list

        Collections.sort(products);  //sorts the elements in products array list

        display(products);  //calls display method by passing products arraylist

        System.out.print("\nEnter a product or " + QUIT + " to quit >> ");  //keeps prompting user to enter a product or enter quit to exit

        entry = input.nextLine();        }    }  //reads the entry value from user

  public static void display(ArrayList products)    {  // method to display the list of products

     System.out.println("\nThe size of the list is " + products.size());  //displays the size of the array list named products

     for(int x = 0; x < products.size(); ++x)  //iterates through the arraylist products

        System.out.println(products.get(x));    }  } //displays each item/element in products array list

Explanation:

In the code the following statement are corrected:

1.

ArrayListproducts = new ArrayList();

This gave an error: cannot find symbol

This is corrected to :

 ArrayList<String>products = new ArrayList<String>();

2.

         products.add(shampoo);

         products.add(moisturizer);

         products.add(conditioner);

Here shampoo moisturizer and conditioner are String type items that are to be added to the products so these strings have to be enclosed in quotation marks.

This is corrected to :

     products.add("shampoo");

     products.add("moisturizer");

     products.add("conditioner");

3.

display();

This method is called without giving any arguments to this method. The method display takes an ArrayList as argument so it should be passed the arraylist products to avoid error that actual and formal argument lists differ in length .

This is corrected to :

display(products);

The screenshot of output is attached.

ASAP 20 Points please hurry

Answers

Answer:

All you got to do is type System.out printIn("Study English) etc...

Explanation:

Look at the answer to see if it is right.

Before inserting a preformatted table of contents, what must you do first?
apply heading styles to text
update the table of contents
navigate to the Review tab and the Table of Contents grouping
navigate to the Insert Table of Contents dialog box

Answers

Answer: apply heading styles to text.

Explanation:

what are motherboards

Answers

Answer:

Explanation:

Motherboard

A motherboard is the main printed circuit board in general-purpose computers and other expandable systems. It holds and allows communication between many of the crucial electronic components of a system, such as the central processing unit and memory, and provides connectors for other peripherals

how to unblock a school computer

Answers

Answer: use a vpn

Explanation:

go to Explanation:

apponvps

Create a flowchart designing a solution to the following problem:

Anna has saved $50,000 for a down payment on a house. Your algorithm will ask Anna how much the house she would like to purchase costs (verify that the entered value is at least $10,000 and no more than $1,000,000.) If Anna’s savings is at least 20% of the house cost, provide a message that tells her that she will not have to pay for mortgage insurance. If, however her savings is less than 20%, but more than 10% provide a message that she can still purchase the home but will have to have the insurance. If unfortunately her savings are 10% or less of the home cost provide a message that she is not eligible to purchase the home and tell her the maximum home price she can afford.

Answers

Answer:

The question requires the answer as an attachment

Explanation:

I've added the flowchart as an attachment (See attachment for flowchart)

The flowchart follows the sequence and conditions in the question

Assume that at time 5 no system resources are being used except for the processor and memory. Now consider the following events:
At time 5: P1 executes a command to read from disk unit 3.
At time 15: P5’s time slice expires.
At time 18: P7 executes a command to write to disk unit 3.
At time 20: P3 executes a command to read from disk unit 2.
At time 24: P5 executes a command to write to disk unit 3.
At time 28: P5 is swapped out.
At time 33: An interrupt occurs from disk unit 2: P3’s read is complete.
At time 36: An interrupt occurs from disk unit 3: P1’s read is complete.
At time 38: P8 terminates.
At time 40: An interrupt occurs from disk unit 3: P5’s write is complete.
At time 44: P5 is swapped back in.
At time 48: An interrupt occurs from disk unit 3: P7’s write is complete.
For time 37, identify which state each process is in. If a process is blocked, further identify the event on which it is blocked.

Answers

Answer:

Follows are the solution to this question:

Explanation:

In Time = 22:

The P5 and P8 are in the ready/running state, and the P1, P3, P7 are into the block state for Input/output.

In Time = 37:

The P1, P3, P8 are in the ready/running state, P5 is in the block state. It suspends or swapped out, and P7 is on the block state for Input/output.  

In Time= 47:

The P1, P3, and P5 are in the ready/running state, P7 is on the block state for Input/output, and P8 is in the exit state.

What feature did the 32X add to the Sega Genesis?

Answers

Answer:

ngl why would i know this

Explanation:

It allowed the console to run 32-bit cartridges.

3.2 lesson practice edhesive ​

Answers

Answer:

3.2 Question 1

x = float(input("Enter a number: "))

if (x > 45.6):

   print("Greater than 45.6")

3.2 Question 2

x = float(input("Enter your grade: "))

if (x >= 90):

   print("Great! ")

Explanation:

I hope this works I do not know exactly what you were asking for

Other Questions
Select the correct answer.Which scientist discovered the relationship between electricity and magnetism?OA.Nikola TeslaOBAlessandro VoltaOC.Hans Christian OerstedODIsaac Newton How is Nothukula affected by her interaction with Ashley? -3x^2+4x-2=0standard form and its a b cwith explanation what is the answer to 7 4 + ( 9/3)2 The question How do plants convert sunlight to energy? best represents which of the following?A.)applied scienceB.)astronomyC.)nuclear physicsD.)basic science What was the outcome of the second constitutional convention If the ratio of boys to girls in Mr. Matas class is exactly 2 to 3, then the class could have: What reason supports the claim that playing video games has benefits? A. Another effect is that video games can help students read better.B. But the games have to be fast games. C Scientists gave one group of seven- to thirteen- year-olds a very fast game to play. D. They gave another group a slower game. Identify the correct sentence.A.The song is Sixteen Tons by "Johnny Cash."B.The song is "Sixteen Tons" by Johnny Cash.C.The song is Sixteen Tons by Johnny Cash.D.The song is "Sixteen Tons" by Johnny Cash. guys help me 3(x4)2x+3 of all the different components of a society, Which one do you think is the most important in creating a successful society? 20. Find the perimeter of a rectangle with veticies A(-2, 6), B(-2,-1), C(3,6), and D(3,-1) Which term describes the relationship between L A and 2 B, if the m LA= 84 and m 2 B = 967Avertical.adjacentsupplementaryDcomplementary A bus left Cancun at 7 a.m. with a group of tourists. They travel 200 miles before they stop at the beach. Then they travel an additional 150 miles until the end of their trip at 5 p.m. What was the average speed of the bus? Please help, will reward brainliest! Thank you! Look at picture^^ Which set of ordered pairs represents a relation that is a function?A. {(0, 1), (1, 2), (2,3), (2, 1), (1, 0)}B.{(2, 1), (1, 2), (0, 1), (1, 0), (1,3)}C.{(0, 1), (0, 2), (0, 3), (0, 4), (0,5)}D. {(0,3), (2, 1), (4, 5), (6,5), (3, 1)) I will give Brain list plz help !!!!! On the map above, river A is the __________ River and river B is the __________ River.A. Congo . . . RwenzoriB. Zambezi . . . CongoC. Congo . . . ZambeziD. Zambezi . . . RwenzoriPlease select the best answer from the choices provided A B C D What is the Range:-3y>3all real numbers In dilute aqueous solution, as [H+] increases:A. pH decreasesB. pOH increasesC. [OH-] decreases