#Python Numbers variable
a=12 #print Variable as define format here define is an integer print (a) #output would be #12 #print Variable as integer convert from define format he a=12 is integer hence will print (int(a)) #output would be #12 #print variable as float value from integer as denine print (float(a)) #output would be #12.0 #print variable as complex value from integer as denine #https://docs.python.org/2/library/functions.html#complex print (complex(a)) #output would be #(12+0j) #for float value change to inter will work like as below b=12.12 print (int(b)) #output would be the integer value as #12 # How do we find the variable type from definirion of variable a=12 print (type(a)) #ouput would be #<class 'int'> a=12.1 print (type(a)) #ouput would be #<class 'float'> a=1+2J print (type(a)) #ouput would be #<class 'complex'> a=True print (type(a)) #ouput would be #<class 'bool'> |
Monday, June 3, 2019
Python Tutorial For Beginners : Section -1
Subscribe to:
Post Comments (Atom)
Top ChatGPT Prompts for DevOps Engineers
As a DevOps engineer, your role involves juggling complex tasks such as automation, infrastructure management, CI/CD pipelines, and troubl...
-
sudo apt update sudo apt install ubuntu-desktop sudo apt install tightvncserver sudo apt install gnome-panel gnome-settings-daemon metac...
No comments:
Post a Comment