Posts

Showing posts from July, 2020

Python Lists And List Functions

Python has a set of built-in functions. Function Description abs() Returns the absolute value of a number all() Returns True if all items in an iterable object are true any() Returns True if any item in an iterable object is true ascii() Returns a readable version of an object. Replaces none-ascii characters with escape character bin() Returns the binary version of a number bool() Returns the boolean value of the specified object bytearray() Returns an array of bytes bytes() Returns a bytes object callable() Returns True if the specified object is callable, otherwise False chr() Returns a character from the specified Unicode code. classmethod() Converts a method into a class method compile() Returns the specified source as an object, ready to be executed complex() Returns a complex number delattr() Deletes the specified attribute (property or method) from the specified object dict() Returns a dictionary (Array) dir() Returns a list of the specified object's prop

String function in python

mystr = "Harry is a good boy" # print(len(mystr)) # print(mystr[::-2]) print(mystr.endswith("bdoy")) print(mystr.count("o")) print(mystr.capitalize()) print(mystr.replace("is", "are")) String function In Python Method Description capitalize() Converts the first character to upper case casefold() Converts string into lower case center() Returns a centered string count() Returns the number of times a specified value occurs in a string encode() Returns an encoded version of the string endswith() Returns true if the string ends with the specified value expandtabs() Sets the tab size of the string find() Searches the string for a specified value and returns the position of where it was found format() Formats specified values in a string format_map() Formats specified values in a string index() Searches the string for a specified value and returns the position of where it was found isalnum() Returns True if all char

Tutorial 7 variable in Python

var1 = "54" var4 = "32" var2 = 4 var3 = 36.7 # print(100 * str(int(var1) + int(var4)) ) # print(100 * "Hello world\n") # print("Enter your number") # inpnum = input() # # print("You entered", int(inpnum)+10) """ str() int() float() """ """ Quiz - Solved in the video Exercise - Next video Project - Some awesome python utility """ # print(type(var1)) print ( "Enter first number" ) n1 = input () print ( "Enter second number" ) n2 = input () print ( "Sum of these two numbers is" , int (n1) + int (n2))