Skip to main content

Posts

Python Arithmetic

Python Arithmetic Expression syntax is straightforward: the operators +, -, * and / work just like in most other languages print ( 2 + 2) print ( 50 - 5 * 6) print ( ( 50 - 5 * 6 ) / 4) print ( 8 / 5)

Python Control Flow

Python Control Flow if Statements The if statement is used for conditional execution x = 5 if x < 0 : print ( 'x is Negative' ) elif x == 0 : print ( 'x is Zero' ) elif x > 0 : print ( 'x is Positive' ) else : print ( 'x is not a number' ) The while statement The while statement is used for repeated execution as long as an expression is true x = 0 while x < 6 : print ( x ) x = x + 1 : for Statements In Python’s for statement iterates over the items of any sequence (a list or a string) fruits = ["apple", "orange", "banana", "cherry"] for fruit in fruits : print ( fruit ) The range() Function If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy. It generates arithmetic progressions for i in range ( 5 ): print ( i ) Output 0 1 2 3 4 More example on range range ( 5 , 10 )...

Python Variables

Python Variables Variables are containers for storing data values. Unlike other programming languages, Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. x = 5 y = "John" print (x) print (y) Variables do not need to be declared with any particular type and can even change type after they have been set. x = 5 # x is integer x = "John" # now x is a string Assign Value to Multiple Variables x, y = 5, 'John' print(x) print (y) You can also use the + character to add a variable to another variable x = "Python is" y = "awesome" print (x + y)

Python Comments

Python Comments In this post, We will learn about comments in Python. Comments can be used to explain Python code. Comments can be used to make the code more readable Single line comment # this is the first comment print ("Hello World") print ("Hello World") # this is the first comment Multi-line comment   # this is a comment # written in # more than on line "print ("Hello World") ''' this is a comment written in more than on line ''' "print ("Hello World")

Python Getting Started

Python Getting Started In this post, We will learn how to write first program in Python. Installation  Many system will have already Python installed. To check Python installed on Windows operating system run below command on windows command shell (cmd.exe). python --version To check Python installed on linux operating system run below command on Linux terminal. python --version Python Quick start Create a Python file hello_world.py here .py extension indicate that it is a python file. Let's write first Python program. Open hello_world.py in text editor and write below program in it. print ("Hello World") Run python file on command line. The way to run a python file is like this on the command line python hello_world.py Above program will print Hello World on your terminal.

Supplementary angles

Supplementary angles Supplementary angles  are two angles with a sum of  180 ^\circ 1 8 0 ∘ 180, degree . A common case is when they lie on the same side of a straight line.

Complementary Angle

Complementary Angle Complementary angles  are two angles with a sum of  90 ^\circ 9 0 ∘ 90, degree . A common case is when they form a right angle

Docker Installation Error

Docker Installation Error docker info Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/info: dial unix /var/run/docker.sock: connect: permission denied sudo docker info Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Fixes Install docker using below command sudo snap install docker

Permutations and Combination

Permutations and Combination Permutations and Combination is one section of the CAT Quantitative Aptitude which needs the least number of formulae and the maximum amount of logic. This topic is asked in almost every competitive exam, so don’t take the risk of avoiding it.  After reading this article you will be familiar with Permutation and Combination. Definition of Permutation : Permutation is defined as the arrangement of r things that can be done out of total n things. Formula of Permutation Permutation is denoted by  nPr   it is equal to  n!/(n-r)! Defination of Combination: Combination is defined as selection of r things that can be done out of total n things. Formula of Combination Combination is denoted  nCr it is equal to n!/r!(n-r)! Fundamental principle of counting Product Rule: If an activity A can be done in “m” ways and an another activity “B” can be done in “n” ways, A and B together can be done in “m x n” ways Example: How ma...

Logarithm

Logarithm When a x   = N , then we say that x = logarithm of N to the base a and write it as x = log a N . In simple words, it represents the power to which a number must be raised. Let me expand on that by giving a simpler example. If we are asked, what would be the result if ‘a’ is multiplied with itself ‘b’ times; then your answer would be x = a*a*a*…. b (times). This can also be written as a^b. This is also known as ‘a raised to the power of b’ If we are asked, which number multiplied with itself ‘b’ times, will result in a; then you are asked for the value of x such that x*x*x*… b(times) = a => x^b = a => x = a^(1/b) This is also known as ‘bth root of a’ If swe are asked, how many times should you multiply ‘a’ with itself to get ‘b’, that is where the concept of logarithm comes into the picture. You are asked for the value of ‘x’ such that a*a*a…. x (times) = b => x = Log  a  b This is also known as ‘ Log b to the base a’ ...