Question

Using Python Programming Language:

4. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_

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

Below is the python solution with output screenshot

Note : I have also commented the code for better understanding

Code :

def print_matrix_char(matrix):
    # print the number of rows and column
    print("Number of rows:", len(matrix))
    print("Number of columns:", len(matrix[0]))
    # print the new line 
    print()
    print("\t", end="")
    # first print the upper line for columns
    for i in range(len(matrix[0])):
        print(i,end="\t")
    print()
    # print the matrix
    for i in range(len(matrix)):
        # print the row number
        print(i,end="\t")
        for j in range(len(matrix[0])):
            print(matrix[i][j],end = "\t")
        print()

if __name__ == "__main__":
    matrix = [['c', 'u', 'r', 'i'],
              ['z', 'y', 'c', 'x'],
              ['e', 'q', 'y', 'm']]
    print_matrix_char(matrix)

Note : for better formatting please refer to the code screenshot below

1 3 4 5 6 7 8 9 def print_matrix_char(matrix): # print the number of rows and column print(Number of rows:, len(matrix)) pr

Output :

C:\Users\lenovo\Desktop solution>python solution.py Number of rows: 3 Number of columns: 4 1 2 3 i C u r Z с х 1 2 у a e у m

Add a comment
Know the answer?
Add Answer to:
Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test...
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
  • Implement the following function in the PyDev module functions.py and test it from a PyDev module...

    Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_matrix_char (matrix): وق في ال Prints the contents of a 2D list of strings in a formatted table. Prints row and column headings. Use: print_matrix_char (matrix) Parameters: matrix Returns None. a 2D list of strings (2D list) w Sample testing: Number of rows: 3 Number of columns: 4 0 1 2 3 i 0 C u r 1 Z 2 Y...

  • 11. Implement the following function in the PyDev module functions.py and test it from a PyDev...

    11. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t11.py: def find_word_vertical(matrix, word): Look for word in each column of the given matrix of characters. Returns a list of indexes of all column that are equal to word. Returns an empty list if no column is equal to word. Use: cols - find_word_vertical(matrix, word) Parameters: matrix - the matrix of characters (2D list of str) word - the word to search...

  • Implement the following function in the PyDev module functions.py and test it from a PyDev module...

    Implement the following function in the PyDev module functions.py and test it from a PyDev module named t15.py: def matrix_equal (matrixi, matrix2): i.e. have the Compares two matrices to see if they are equal same contents in the same locations. Use: equal matrix_equal (matrix1, matrix2) Parameters: matrix1 the first matrix (2D list of ?) matrix2 the second matrix (2D list of ?) Returns: equal True if matrix and matrix2 are equal, False otherwise (boolean) NMN Sample testing First matrix: 0...

  • Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns...

    Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns all the items of each list concatenated together into one new 1D list. For example: flatten ([["a", "b"],["c","0"],["e","f"]]) would return ["a", "b","C","d", "e","f"] Save the function in a PyDev library module named functions.py Write a program t03.py that tests flatten function and prints the returned flat list to the screen. Test your program with a different list, hardcoded in t03.py • Copy the results...

  • The following must be coded using Python programming language: In this assignment you will implement two...

    The following must be coded using Python programming language: In this assignment you will implement two programs: a chat client and a server. The server will listen to a known port for new connections from clients. When a client connects, it will be able to authenticate with the server and then join a chat room and send messages.

  • Python Programming language Write the following functions: getNumInRange(prompt, min, max) - get...

    Python Programming language Write the following functions: getNumInRange(prompt, min, max) - gets a number from the user within the specified range, prompting with 'prompt' calcAvg(values) - calculates and returns the average from a supplied list of numeric values menu(somelist) - creates a numbered menu from a list of strings. Then, have the user select a valid choice (number), and return it. Use the getNumInRange() funtion to do this. getAlbum() - prompts the user for information to populate a dictionary representing...

  • Python Language. Question 5 Next, you are asked to implement a Python function called compareScoreStrings(), that...

    Python Language. Question 5 Next, you are asked to implement a Python function called compareScoreStrings(), that will take in the score strings for two players and analyze them, returning information comparing the two. The function specification you need to adhere to is given below. Note that you can assume scoreStringAnalysis () from the previous question has been implemented and you can call it if needed. def compareScoreStrings (pistring, p2string): Given score strings for two players, determine: - which player was...

  • 11.3 (Subclasses of Account) In Programming Exercise 9.7, the Account class was defined to model a...

    11.3 (Subclasses of Account) In Programming Exercise 9.7, the Account class was defined to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and with- draw funds. Create two subclasses for checking and saving accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn. Draw the UML diagram for the classes and implement them. Write a test program that creates objects of...

  • In C Programming Language In this lab you will implement 4 string functions, two using array...

    In C Programming Language In this lab you will implement 4 string functions, two using array notation and two using pointers. The functions must have the signatures given below. You may not use any C library string functions. The functions are 1. int my strlen (char s ) - This function returns the number of characters in a string. You should use array notation for this function. 2. int my strcpy (char s [], char t I)- This function overwrites...

  • USING PYTHON PROGRAMMING LANGUAGE CELSIUS FUNCTION: def convertF(fTemp): c = (fTemp - 32) * (5 / 9) print(fTemp, "F...

    USING PYTHON PROGRAMMING LANGUAGE CELSIUS FUNCTION: def convertF(fTemp): c = (fTemp - 32) * (5 / 9) print(fTemp, "Fahrenheit is equal to %.0f" % c, "Celsius.") fTemp = float(input("Enter Fahrenheit temp to convert: ")) convertF(fTemp) 2.3. Do you think Python will print anything different if you pass a floating point number to celsius? What would Python print for this expression? Explain >>>celsius(60.0) 24. Do you think the celsius function can deal with negative numbers? What will Python do with this...

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
ADVERTISEMENT