Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:12:16+00:00 2026-06-14T10:12:16+00:00

I have been given some ready made code and an input and expected output

  • 0

I have been given some ready made code and an input and expected output now I need to find a way to calculate the output from the input

This is the code I have been given

3 2 4

T T
F F
T T

F F F F
T T T T

and i have been asked to calculate the logical matrix P=mn

resolved

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:12:17+00:00Added an answer on June 14, 2026 at 10:12 am
     for i in range(len(M)):
         for j in range(len(N[0])):
             for k in range(len(N)):
                 P[i][j] += M[i][k] * N[k][j]
    

    This is the basic schema for matrix containing integers.
    You have to do 2 steps:
    1) Initiate the P matrix
    2) Operate with ‘T’ and ‘F’ values instead of integers.

    Probably the simplest way to accomplish the step 2 is to use eval function:

    T = 1  # eval('T') will be 1
    F = 0  # eval('F') will be 0
    

    And change the line:

    P[i][j] += eval(M[i][k]) * eval(N[k][j])
    

    But you still need to convert the values from P to ‘T’ or ‘F’ values. Hope this helps.

    M = [['T', 'T'], ['F', 'F'], ['T', 'T']]             #sample values
    N = [['F', 'F', 'F', 'F'], ['T', 'T', 'T', 'T']]
    
    T = 1
    F = 0
    
    P = [] 
    
    for i in range(len(M)):                              #result matrix creation
        P.append([None] * len(N[0]))
    
    for i in range(len(M)):
        for j in range(len(N[0])):
            P[i][j] = 0                                  #initialization
            for k in range(len(N)):
                P[i][j] |= eval(M[i][k]) & eval(N[k][j]) #logical operators
            P[i][j] = 'T' if P[i][j] else 'F'            #conversion back to 'T' and 'F'
    
    print P
    

    This produces the output:

    [['T', 'T', 'T', 'T'], ['F', 'F', 'F', 'F'], ['T', 'T', 'T', 'T']]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been given some poorly formatted data and need to pull numbers out
I have been given some matlab code compiled using the .net compiler. I can
I have been given some generated code which looks like so: <form id=form1 method=post
I have been given the task of re-writing some libraries written in C# so
I have been given some 'reports' from another piece of software that contains data
I've been given some XML files that don't quite have a proper schema (I
I have been given control of a web site in Classic ASP. What is
I have been given an exercise to solve the zebra puzzle using a constraint
I have been given the below .NET question in an interview. I don’t know
We have been given a site xyz.com, in which the home page has images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.