Question

USING PYTHON IDLE 3.4:

OUTPUT should look like this:

galaxies.txt

O
P
!
!
E
O
R
U
B
R
!
!
!
B
O
I
B
R
R
P
P
B
O
O
B
!
P
I
!
E
!
L
I
!
L
R
P
B
L
E
I
O
I
P
I
I
L
U
B
L
P
B
B
R
!
R
L
!
R
R
P
!
L
L
P
P
E
P
B
B
E
R
U
R
P
!
P
B
I
U
L
L
I
U
B
R
B
U
L
R
L
B
U
I
R
R
E
P
L
P

cycles.txt

8
4
4
10
8
10
8
4
10
4
8
2
4
8
8
8
8
8
4
2
2
4
10
2
6
6
10
10
2
4
4
10
6
6
2
2
8
10
8
2
8
8
2
8
8
2
10
8
8
4
8
6
2
2
8
4
4
8
4
10
8
10
2
8
8
2
4
2
10
2
8
8
8
8
4
4
4
8
10
10
8
8
6
2
8
6
8
10
8
10
2
8
10
8
8
8
6
8
8
10

Need help with this please! :( Need to use the List Comprehension format: [expression for variable in sequence if condition] as stated in introduction!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# labprep8.py

# Poonam R

# This is an optimization of an earlier Python file i/o program

# which program combines data from the BOOYA Observation Lab

def combineX():

    File1 = input("Enter FilenName for 1st file(like Galaxies.txt) : ")

    File2 = input("Enter FilenName for 2nd file(like cycles.txt) : ")

    print("The combineX() function analyzes BBOYa data")

    print("===========================================")

    print("Data from 2 files will be analyzed:")

    print("Report of BOOYA Radio Galaxy Observations")

   

    HandleFile1 = open(File1)

    HandleFile2 = open(File2)

    print("\nTwo files are opened")

   

    print("Reading from " + File1)

   

    lstFile1 = [line.strip() for line in HandleFile1]

   

    print("Reading from " + File2)

    HandleFile2 = open(File2)

    lstFile2 = [line.strip() for line in HandleFile2]

    return lstFile1,lstFile2

def main():

    specialchar = ['(', '\\', ')' ,'"',"'" ]

    lst1,lst2 = combineX()

   

    print("Removing the extra spaces and special character")

    lst1 = list(filter(("").__ne__, lst1))

    for symbol in specialchar:

        lst1 = list(filter((symbol).__ne__, lst1))

   

    lst2 = list(filter(("").__ne__, lst2))

    for symbol in specialchar:

        lst2 = list(filter((symbol).__ne__, lst2))

       

    print("Combinig two values and appended to the list")

    FinalList=(list(zip(lst1, lst2)))

   

    cnt=1

    for i in range(len(FinalList)):

        print(FinalList[i][0] + FinalList[i][1],end=' ')

        cnt=cnt+1

        if cnt>5:

            cnt=1

            print()

if __name__=='__main__':

    main()

Output Screenshot

Add a comment
Know the answer?
Add Answer to:
USING PYTHON IDLE 3.4: OUTPUT should look like this: galaxies.txt O P ! ! E O...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a python program that writes to an output file "decoder.txt" a table of letters as...

    Write a python program that writes to an output file "decoder.txt" a table of letters as follows: ___1_2_3_4_5 1: A B C D E 2: F G H I K 3: L M N O P 4: Q R S T U 5: V W X Y Z Note that the letter J has been removed. Use string.ascii_uppercase to start

  • Hello can anyone help solve this please in Python the way it's asked? Question 22 40 pts List Comprehensions Write...

    Hello can anyone help solve this please in Python the way it's asked? Question 22 40 pts List Comprehensions Write the solution to a file named p2.py and upload it here. Comprehensions will show up at the midterm exam, so it's important to practice. a) Write a list comprehension that returns a list [0, 1,4, 9, 16, .. 625] starting from range(0, 26). (lots of list elements were omitted in ...) b) Write a list comprehension that returns the list...

  • Word Bank: a) python b) computer science c) algorithm d) program e) interpreter f) compiler g)...

    Word Bank: a) python b) computer science c) algorithm d) program e) interpreter f) compiler g) syntax h) semantics i) value J) variable k) operator l) operand m) expression n) statement o) input p)output q)call r) arguments s) library t) bug u) variable scope v) local variable w)global variable x) variable lifetime y) relational operators z) logical operators 1) Compares operands and results in a bool: 2) The duration of a variable's existence: 3) A list of instructions to solve...

  • Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42,...

    Please explain the python code below L1 = [2, 15, 'Carol', 7.4, 0, -10, -6, 42, 27, -1, 2.0, 'hello', [2, 4], 23] print("L1 =",L1) odds =[] evens=[] list=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',',','.'] no=0 for i in L1: i=str(i) for j in list: if i.find(j)>=0: no=1 if no==1: None else: i=int(i) if i%2==0: evens.append(i) else: odds.append(i) no=0      ...

  • This is a Python Program Write a program that encrypts letters based on the following key....

    This is a Python Program Write a program that encrypts letters based on the following key. Original letter to encrypted letter A M B L C K D J E I F H G G H F I E J D K C L B M A N Z O Y P X Q W R V S U T T U S V R W Q X P Y O Z N Write the output to a file

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : You are given a non-decreasing sequence of n positive integers a1,a2,…,an. Print the number of distinct values in the sequence. For example, if the sequence is 1,2,2,2,3,4,4,5,7,10, the answer is 6 since distinct values are 1,2,3,4,5,7,10. Input The first line contains a positive integer n (1≤n≤1000) — the length of the sequence. The second line contains n space-separated positive integers a1,a2,…,an (1≤ai≤1000)...

  • (Same-number subsequence) Write an O(n) program in python that prompts the user to enter a sequence...

    (Same-number subsequence) Write an O(n) program in python that prompts the user to enter a sequence of integers and finds longest subsequence with the same number. Here is a sample run of the program: <Output> Enter a series of numbers ending with 0: 2 4 4 8 8 8 8 2 4 4 0 The longest same number sequence starts at index 3 with 4 values of 8 <End Output>

  • Python please 2. For the list a - 1-1,8,21,tuple b-(5,1,-3), and ndarray c -np.array (11,1,21) determine...

    Python please 2. For the list a - 1-1,8,21,tuple b-(5,1,-3), and ndarray c -np.array (11,1,21) determine the results of the following expressions and place them in the spaces on the right of the table. If the expression would return an error, write "error" as the result. Note that each expression is independent of the others. (12 pts) Expression Results a*o.5 b*o.5 c*o.s a+3 b+3 c+3 a+I-2] at[-2] *2 a [O] -4; print (a) ; bt0-4; print (b) c[0] -4; print...

  • Need in Python! Consider the following program and expected output. Rewrite it using a for loop...

    Need in Python! Consider the following program and expected output. Rewrite it using a for loop and a conditional break statement such that it has the same output.   HINT: Stay with i as the main loop counter and let j control the break behavior.   i = 0 while i < 10 and j < 10 : j = i * 2 print(i, j) i += 1 # Output below, for reference - not part of the program! 0 0 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT