Posts

Showing posts from July, 2020

Python Operators

Arithmetic Operators print(10+3)    13 print(10-2)      8 print(10*3)     30 print(10/3)      3.3333333333333335  this ( / ) operator will always return a floating value print(10/2)      5i.0 print(10//3)     3 and this ( // ) will return an integer value  print(10//2)    5 print(10%3)   1 print(10**3)   1000 this ( ** ) operator is power of operator. Assignment operators x==3 Following are augmented or enhanced assignment operators x+=3 x*=3  x/=3  x//=3 x%=3       Operator precedence Parenthesis Exponantiation or power multiplication  division / or //               <<<doubt which first modulus addition subtraction

Python string functions

string_name.upper() // to change all letter to upper case string_name.lowe()   // to change all letters to lower string_name.len()     // returns the length of string. string_name.find("string to be founded") // if not present than return -1 else returns the index position     (0-based) in function is a boolean variables that returns True or false. Ex. course="python for programmers";        print("python" in course); output : True.            //Note : The boolean variables are case sensitive, i.e, True is correct but true is useless, same  False is correct but false is useless . string_name.replace("string to be replaced","new string") // replaces only when string to be replaced is found. Formatted strings -    f ' --{}---{}---' These can be used to print stings with values of variables like; Ex- first= 'Ram' ; last = 'mango' ; msg= f ' Hello {first} , is this {last} your favourite fru...

GCD

The inbuilt function to find the GCD is; __gcd(variable, variable2); d=__gcd(a,b); or d=__gcd(a,gcd(b,c)); or d=__gcd(gcd(a,b),gcd(c,e)); note ::: that the datatype of variable can only be int;