Skip to main content

python prgram for matrix addition (user based input )without using numpy or array

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 13 14:25:56 2018

@author: beast
Note this program is for holding int value to list only """
def addmatrix():
    matrixA=list() # intialize matrix as empty list
    matrixB=list() #intialize matrix as empty 
    matrixS=list() #store the sum 
    
    try:
        row,col=[int(j) for j in (input("Enter the row and col ").split())]
        print(row,col)
        inp=""
    except ValueError:
            print("Please Enter row and col seperated by space eg: 2 2") 
            inmatrix()
    
    for i in range(row):
        for j in range(col):
                inp+=((input("Enter the number for matrix A[%d][%d}--->"%(i,j)))+",")
        try:
            lst=[int(a) for a in inp.split(",") if a!=""]#delete int for making it to hold any data 
            # create a list using input row string 
            matrixA.append(lst) #add the row wise data 
            inp="" #after eacch row input reset inp to get next input 
        except ValueError:
            print("please Enter Integer Only as list input\n\a------ Restarting ---\n")
            addmatrix()
       
            
#        """now matrix B input ----"""
    print("\n____________________\n")
    for k in range(row):
        for l in range(col):
                inp+=(input("Enter the number for matrix B[%d][%d}--->"%(k,l))+",")
        try:
            lst=[int(a) for a in inp.split(",") if a!=""]#delete int for making it to hold any data 
            # create a list using input row string 
            matrixB.append(lst) #add the row wise data 
            inp="" #after eacch row input reset inp to get next input 
        except ValueError:
            print("please Enter Integer Only as list input\n\a------ Restarting ---\n")
            addmatrix()
    print("\n------------\nmatrix A-->\n",matrixA) 
    print("\nmatrix B-->\n",matrixB) 
        
    for m in range(row):
        temp=list()
        for n in range(col):
             temp.append(matrixA[m][n]+matrixB[m][n])
          
        matrixS.append(temp) # add the result rowwise as a list 
    print("\n-----------result----------\n")
    
#    print(matrixS)        
    return matrixS
    

    
if __name__=="__main__":
    try:
        print(addmatrix())   
    except Exception:
        print("please Give Correct Input\n")
        addmatrix()

Comments

Popular posts from this blog

13 websites to register your free domain

Register your Free Domain Now!! 1)  .tk Dot TK is a FREE domain registry for websites on the Internet. It has exactly the same power as other domain extensions, but it’s free! Because it’s free, millions of others have been using .TK domains since 2001 – which makes .TK powerful and very recognizable.  Your website will be like www.yourdomainname.tk . It is free for 1 year. It’s a ccTLD domain whixh having the abbreviation  Tokelau. To create a .tk domain, Visit   www.dot.tk 2) co.cc Co.cc is completely free domain which is mostly used by blogspot bloggers because of it’s easy to use DNS system. Creating a co.cc for blogger is simple ( for instructions- “click here”). Your website will be like www.yourdomainname.co.cc . To create a .co.cc domain, visit www.co.cc 3)   co.nr co.nr is too like co.cc. Your website will be like  www.yourdomainname.co.nr . You can add it for blogger also.. To create a .co.cc domain, vi...

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to  increase the revenue  and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase  Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other  blog monetization methods  as well to effectively monetize y...

what is LOREM ipsum and why do designers use it

What is Lorem Ipsum? Lorem Ipsum  is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now...

Binary Search Tree in Java implementation (reference based, dynamic memory)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 import java.util.Scanner ; class BST { static BST . Node root = null ; public void insert ( int num ) { if ( root == null ) { root = new BST . Node ( num ); } else { // root node is not empty BST . Node temp = root ; while ( temp != null ) { if ( num <= temp . getVal ()) { if ( temp . getLeft () != null ) temp = temp . getLeft (); ...

What Are Search Engine Spiders?

A spider, also known as a robot or a crawler, is actually just a program that follows, or "crawls", links throughout the Internet, grabbing content from sites and adding it to search engine indexes. Spiders only can follow links from one page to another and from one site to another. That is the primary reason why links to your site (inbound links) are so important. Links to your website from other websites will give the search engine spiders more "food" to chew on. The more times they find links to your site, the more times they will stop by and visit. Google especially relies on its spiders to create their vast index of listings. Spiders find Web pages by following links from other Web pages, but you can also submit your Web pages directly to a search engine or directory and request a visit by their spider. In fact, it's a good idea to manually submit your site to a human-edited directory such as Yahoo, and usually spiders from other search e...

Batch file to C++ souce code generator ...

Batch file to C++ souce code generator ... Well this project was made upon CODEBLOCK using c++ HERE IS THE SOURCE CODE: download it as .cpp form by clicking here.. mirror 1                                                   mirror 2. One drive if YOu want the exe file only then click here (500 KB) Mirror 1. MULTCLOUD  FOR PASSWORD TO THIS SITE VISIT THE FOLLOWING LINK OR SUMBIT THE FORM BELOW  >>> LINK :   https://goo.gl/forms/DiQHvEjfavsaU18U2                              or Loading...

SQL Server 2016 RTM full and final version available – Download it

–> Download SQL Server: To download SQL Server 2016 you can  Register and Download  the SQL Server 2016 Full or free Evaluation version (180 days) here. Or you can  Direct download  the DVD ISO file image (~2.1 GB)  SQLServer2016-x64-ENU.iso   –> Free Developer Version: Microsoft on March 2016 announced that going forward the Developer version of SQL Server any release will be free for Developers and Learning purpose.  Register and Download  the Developer version. Or you can  Directly download  the DVD ISO image (~2.1 GB):  en_sql_server_2016_developer_x64_dvd_8777069.iso This  Developer version  is meant for  development and testing  only, and  not for production environments  or for use with production data. For more info please check my  previous blog post .   –> One big Update on SSMS: From now onward SSMS i.e. SQL Server Management Studio will not be part of SQL ...

Facebook's First Layout

... More about fb: Facebook paid a whooping $8.5 Million to buy "Fb.com" domain!! So next time instead of typing "facebook.com" you can just type in "Fb.com" to save time!! Facebook acquired the domain sometime last year from the American Farm Bureau Federation, which uses fb.org as its primary domain. At its annual meeting in Atlanta, the non-profit revealed that it earned $8.5 million on the sale of fb.com The last high-profile domain purchase by Facebook was for Facebook.com, all the way back when it was known as TheFacebook. The company paid $200,000 in August 2005 to acquire the domain, 42.5 times less than what Facebook spent to acquire fb.com. While the Facebook.com purchase was expensive for the company back then, it’s an investment that has clearly paid off. The company is obviously hoping that fb.com will also pay off. source: https://en.wikipedia.org/wiki/File:Original-facebook.jpg

FIXED: Feedjit gadgets no longer work on my blog!!! help

well if your feedjit tracker is not working than you can easily fix this... goto blogger.com Go to  Dashboard -> Settings And set  HTTPS Redirect  to  No The gadgets will work now for  http ://yourblog.blogspot.com They won't for  https ://yourblog.blogspot.com because their connection isn't secure. this is not a permanent fix ... the gadget developers will have to make their gadgets https ready before Blogger will (if at all) become https only.

DOWNLOAD CODE BLOCKS 16.01 MINGW.SETUP .EXE 86.3 MB

Code::Blocks for Mac is a free C, C++ and Fortran IDE that has a custom build system and optional Make support. The application has been designed to be very extensible and fully configurable. Code::Blocks is an IDE packed full of all the features you will need. It has a consistent look, feel and operation across its supported platforms. It has been built around a plugin framework, therefore Code::Blocks can be extended with plugins. Support for any kind of functionality can be added by installing/coding a plugin. Key features include: Written in C++. No interpreted languages or proprietary libs needed.. Full plugin support. Multiple compiler support: GCC (MingW / GNU GCC), MSVC++, clang, Digital Mars, Borland C++ 5.5, and Open Watcom etc. Support for parallel builds. Imports Dev-C++ projects. Debugger with full breakpoints support. Cross-platform. Code::Blocks' interface is both customizable and extensible with Syntax highlighting, a tabbed interface, Class Br...