IO OPERATIONS ============== IO ==> INPUT AND OUTPUT INPUT OPERATION: ================ TAKING OF THE DATA FROM THE KEYBOARD WHILE THE PROGRAM IS RUNNING OR READING OF THE DATA pre-defined method: input() Syntax for input() ============== identifier = input() or identifier = input("Enter some text") ==> using the input(), we can allowed to read any data. OUTPUT OPERATION ================== WRITING/DISPLAYING OF ANYTHING ON THE SCREEN PRE-DEFINED METHOD: print() Syntax for print() ============== 1) printing of single value ===================== print(name of the value) 2) printing of more than one value using single print() ============================================ print(name1,name2,name3,...) Note: ==== print() ==> by default reserve with new line. 3) printing of a value along with message ================================= First value = 123 Second value = 234 123 is the first value 234 is the second value The First value is : 123, The Second value is: 234 123 is the first value and 234 is the second value print("message with single quote or double quote",name of the value) print(name of the value,"message with single quotes or double quotes") print("message",name of the value,"message",name of the value) print(name of the value,"message",name of the value,"message") 4) printing of values along with messages with % symbol ============================================== ==> formatting of data with % print("message %s"%(name of the value)) # for single value with message print("message %s message %s message %s"%(name1,name2,name3)) # for more values along with messages 5) using format() ============= print("Message {}".format(name of the data)) print("Message {} "message {}".format(name1,name2)) print("Message {dummy name1} message {dummy name2}".format(dummy name1 = name1,dummy name2 = name2)) print("message {3} message {1} message {2}".format(name1,name2,name3)) a = input() # we can't get any message screen to make confirm that why console is waiting b = input("Enter something:") # the text or message make you confirm that why console is waiting # printing single values print(a) # first value print(b) # second value # printing of more than one values print(a,b) # here printing of all values within the same line is possible # PRINTING VALUES ALONG WITH MESSAGES print("The Value of a = ",a) print('The Value of b = ',b) print(a,"is the value for a") print(b,'is the value for b') print("The Value of a = ",a,"and The Value of b = ",b) print(a,": is the value of a ",b,': is the value of b') # formatted output print("The value of a is : %s"%(a)) print('The value of b is : %s'%(b)) print("The Value of a is: %s and the value of b is: %s"%(a,b)) # using format() print("The Value of a = {}".format(a)) print('The Value of b = {}'.format(b)) print("The value of a = {} and the value of b = {}".format(a,b)) print("The value of a = {x} and the value of b = {y}".format(x = a,y = b)) print("The Value of a = {1} and the value of b = {0}".format(a,b)) ============================================================================= DATATYPES ========== ==> IN HOW MANY WAYS THE DATA CAN BE REPRESENTED IN PYTHON PROGRAM ==> ALL THE DATATYPES IN PYTHON ARE IN-BUILT/PRE-DEFINED. BECAUSE FOR EVERY DATATYPE, THERE IS ONE PRE-DEFINED CLASS ==> CLASS ==> A COLLECTION OF DATA AND METHODS ==> TO ACCESS THE DATA OF ANY CLASS, WE NEED AN OBJECT. EX: a = 10 ==> 10 in an integer class # 10 is getting accessed using an object 'a' ==> DATATYPES ARE CLASSIFIED INTO: 1) PRIMITIVE DATATYPES/FUNDAMENTAL DATATYPES 2) COLLECTION DATATYPES ==> TO GET THE CLASS NAME OF ANY DATATYPE: WE CAN USE type() 1) PRIMITIVE DATATYPES/FUNDAMENTAL DATATYPES ============================================== ==> classified into: 1) numerical type ==> all the data with only numbers ==> ex: 123, 12.234, 12-23j etc. 2) non-numerical type ==> all the data without numbers ==> True, False 3) text based ==> the data with single quotes or double quotes ==> 'hi', "12345" ==> string data 1) numerical type ============== integers floats complex Note: === python is dynamically typed programming language integers ====== binary ==> base-2 number ==> with only two literals (0 and 1) ==> 0b1100001010010 octal ==> base-8 number ==> with only 8 literals (0 to 7) ==> 0o71023, 0O1100010010 decimal ==> base-10 number ==> with 10 literals (0 to 9) ==> 12345, 10001010101 ==> for the decimals, no prefix is required hexadecimal ==> base-16 number ==> with 16 literals (0 to 9 and alphabets: a to f) ==> 0x12013201, 0Xaf123 Note: any number, can be decoded by the Python Virtual Machine (PVM) (Interpreter) as decimal by default. Note: === print() will always print any value in decimal format by default.