Posts

Showing posts from July, 2020

Object Oriented Programming.

Python is Object Oriented Programming: Overview of object Oriented Programming: Class Classes are defined by the users. The class provide basic strucuture for an object , it consists of data memebers and method member that are used byinstance (object) of the class. Data member: A variable define in either a class or an object, it holds the data associated with the class or object. Instance Variable: A variable that is define in a method. Its scope is within the object that defien its. Class Variable: A variable that is define in the class and can be used by all the instance of that class. Instance: A object is instance of a class. Method: Methods are the function that are define in the definition of the class and used by various instance of the class. Function Overloading: A function define more than one time with different behaviour is known as Function overloading. The operation performed by these functio...

Classes in Python.

Class Definition: A class is define with the keyword 'class' followed by userdefine class name and end with the colon (:) . All the statement which is present inside the class such as variable declaration of function. Syntax: class : variable declaration method declaration: statement inside method Every thing in the class is intended just like code in the function , loop, if statement etc. Any thing not intended is not part of the class. Write a program for a simple class demostration which print the message "hello" class display: def show(self): print("hello") s=display() s.show() Output: hello write a program to add class addition: a=5 b=6 def add(self): print(a+b) aObj=addition() aObj.add() Output: 11 write a program to fill the details of students like its name, branch and year. class student: def fillsdetails(self,name,branch,year): self.name=name self.b...

String is Immutable.

Image
Strings are Immutable: # Mutable: Can change # Immutable: Can not change The String in python are immutable. You can not change an existing character of a string. Let us consider : indexing st="hello" print(st[0]) output: h st[0]="t" output: st type error Type error st object does not support item assignment. The object in this case is the string st and the item is character you try to assign , an object is the same thing as a value and item is one of the value of a sequence. To achieve changes like modification in a String, we can create new String. t="hello" t1='t'+t[1:] print(t1) output: tello Consider the following two similar String "Hello" is assign to two different variables as: str="hello" str2="hello" In the above example str1 and str2 have t...

String in Python.|access string | len() function| Traversal of String.

Image
String: String is a sequence , String is the one of the popular data type in the python, use and manipulatation of string in python is very easy. String is collection of characters , we can create them simply by "" or ''. Python '' same as "". It is as simple as assigning the value to the varible. Example: S1="This sis Python" S2='This is a programming language' >>>"This is String" >>>This id String >>>type("This is String") >>> Strings are example of sequence type as the provide easy way to acccess them. Access string: In python string are store as an individual characters in continueous memory location. The benefit of using string is, it can be access from both the direction i.e forward as well as backward. Both forward and backward index...

Return Statement in Python.

Return Statement: The keyword return is used to return the value after execution of the Statement. Example: def max(n1,n2) : if (n1 > n2): return n1 elif (n1 Output: 6 Returning Multiple Values: It is possible to return multiple value in Python. Example: def arith(n1, n2): return (n1+n2),(n1-n2) print(arith(23,21)) Output: (44,2) Assign Return Multiple Values to Variable: Example: def demo(n1): print(n1) return (n1*n1),(n1*n1*n1) square,cube=demo(3) print("square",square,"cube",cube) Output: 3 square 9 cube 27

Global Statement in Python.

Globa Statement: Global variables are used for the Global scope which is define outside the function of a program. If we wnat to change the global variable value inside the local function then global keword is used to update the new value. Without Global: a=30 def demo(): a=20 print(a) demo() print(a) output: 20 30 With Global: a=30 def demo(): global a a=20 print(a) demo() print(a) output: 20 20

User Phone Number Verification through Firebase in Android Studio.

Image
Add dependency to your "build.gradle " : implementation 'com.google.firebase:firebase-database:16.0.4' implementation 'com.google.firebase:firebase-storage:16.0.4' implementation 'com.google.firebase:firebase-auth:16.0.5' implementation 'com.hbb20:ccp:2.3.2' Add Custom Button to drawable:  <? xml version ="1.0" encoding ="utf-8" ?> <shape xmlns: android ="http://schemas.android.com/apk/res/android" android :shape ="rectangle" > <solid android :color ="#938709" /> <corners android :radius ="25dp" /> </shape> Add custom editText to drawable: <? xml version ="1.0" encoding ="utf-8" ?> <shape xmlns: android ="http://schemas.android.com/apk/res/android" android :shape ="rectangle" > <solid android :color ="#9874a7" /> <corners android :radius ="25dp" /> ...

Design Payment Activity and Store data in Firebase Database in Android Studio.

Image
Fisrt Activity: activity_main.xml <? xml version ="1.0" encoding ="utf-8" ?> <RelativeLayout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" android :layout_width ="match_parent" android :background ="@drawable/money" android :layout_height ="match_parent" tools :context =" .MainActivity" > <Button android :id ="@+id/make_donation" android :layout_width ="match_parent" android :layout_height ="wrap_content" android :layout_alignParentStart ="true" android :layout_alignParentBottom ="true" android :layout_marginStart ="5dp" android :layout_marginBottom ="161dp" android :backg...