diff --git a/README.md b/README.md index fa8ee98..f1f7400 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,26 @@
+## Q.What is Python? +Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. + +It is used for: + +web development (server-side), + +software development, + +mathematics, + +system scripting. + +## Q.What can Python do? +Python can be used on a server to create web applications. +Python can be used alongside software to create workflows. +Python can connect to database systems. It can also read and modify files. +Python can be used to handle big data and perform complex mathematics. +Python can be used for rapid prototyping, or for production-ready software development. + ## Q. How can you improve the following code? ```py @@ -147,8 +167,6 @@ div2(5.,2.) Also, how would the answer differ in Python 3 (assuming, of course, that the above [print] statements were converted to Python 3 syntax)? -- kjalfkjaslf -
↥ back to top
diff --git a/programs/sort_dict_by_value.py b/programs/sort_dict_by_value.py new file mode 100644 index 0000000..481792e --- /dev/null +++ b/programs/sort_dict_by_value.py @@ -0,0 +1,9 @@ +data = { + 'one':1, + 'two':2, + 'four':4, + 'three':3 +} + +sort_dict = {key:val for key,val in sorted(data.items(),key= lambda x : x[1]) } +print(sort_dict) diff --git a/programs/transpose_of_matrix.py b/programs/transpose_of_matrix.py new file mode 100644 index 0000000..a4b4dfe --- /dev/null +++ b/programs/transpose_of_matrix.py @@ -0,0 +1,22 @@ +class Matrix(object): + def __init__(self,mat = None): + self.mat = mat + + def get_matrix(self) -> list: + return self.mat + + def transpose(self) -> list: + if self.mat: + try: + return list(zip(*self.mat)) + except Exception as e: + return f"Failed to convert transpose because {e}" +mat = [ + [1,2,3], + [4,5,6], + [7,8,9] + ] + +matrix_obj = Matrix(mat) +print(f"Original Matrix is : \n {matrix_obj.get_matrix()}") +print(f"Transpose of above matrix is : \n {matrix_obj.transpose()}")