# '==' : value equality-two objects have the same value # is : reference equality- two references refer to the same object a=[ 1 , 2 , 3 ] b=a #two references refer to the same object(b is not the copy of a) print (b==a) print (b is a) c=a[:] #two references refer to the two different object(now c is the copy of a) print (c==a) print (c is a)
#json (java script object notation) is a standardized format commonly used to transfer data as text #from web application to server and vice versa. #json is a built in module in python import json #loads method used to convert json format to python jsonstr= '{"name":"harish","goal":"engineer","channel":"softwareharish"}' #json string parse=json.loads(jsonstr) #convert json string to python print (parse[ "goal" ]) print (parse) #dumps method used to convert python to json format dic1={ "name" : "harish" , "goal" : "engineer" , "channel" : "softwareharish" , "subscribers" : 1000 , "watchtime" : 2000 , "israj" : False } x=json.dumps(dic1) #convert python to json string print ( "json string \n " , x)
//different methods to take a string from user #include <stdio.h> int main () { char str1 [ 10 ]; printf ( "enter a string:" ); gets ( str1 ); //method 1: using gets function printf ( " %s \n " , str1 ); char str2 [ 10 ]; printf ( "enter a string:" ); scanf ( " %s " ,& str2 ); //method 2:using scanf, but with this we cannot use white spaces in string printf ( " %s \n " , str2 ); printf ( "using puts displaying string output \n " ); puts ( str2 ); //puts function is used to display string output return 0 ; }
Comments
Post a Comment