welcome to crazy coding stuffs
For Beginners in python
hey, there lets talk about some more concepts about python 😎
Remember!!!
" do you know, In python everything is considered as object"
lets know about variables in python...
what is variables in python???
"variables in python is a reserved memory locations to store the values"
syntax:
variable=value.
Ex:
x=10 -> here 'x' is variable and '10' is value
y=20 ->here 'y' is variable and '20' is value
Actually, there are some Rules that we have to follow while declaring a variables.
- python variables is also known as "Identifiers" and used to hold the values.
- In python we don't need to specify the type of variable because python is infer language and smart enough to get variable type
- variables names can be group of both the Letters and Digits, but they have to begin with a Letter or Underscore
- It is recommended to use Lowercase letters for the variable names.
- In python language all the Keywords are in Lowercase except ''None'' ,''True'' and ''False''
- variables are case sensitive
if you want to read the value of a variables from user means, you have to follow below step:
exam1.py
var_1=int(input("Enter the integer value/n")
var_2=float(input("Enter the Floating value/n)
var_3=input("Enter your Name/n)
print("The value of Integer is :-> " , var_1)
print("The value of Float is :-> , var_2)
print("My name is :->,var_3)
output:
Enter the integer value: 10
Enter the floating value: 10.10
Enter your name: Ravikumar
The value of integer is : 10
The Value of float is : 10.1
My name is : crazy
what is Identifiers ???
"Identifiers are nothing but Name given to Element of the program like Variable name, Function Name, Module Name , Task Name ."
The Identifiers used to recognize the element of the program.
here also we have some Rules to follow while defining a Identifier.
- The first Character of the Variable must be an Alphabet or Underscore (_)
- All the Characters except the first character may be an alphabet of lowercase(a-z) ,uppercase(A-Z), underscore, or Digit(0-9)
- Identifier Name must not contain whitespace or special Character(!,@,#,%,&,*)
- Identifier Name must not be similar to any keyword defined in the language.
- identifier Names are case sensitive Ex: myname,MyName is not the same .
- keywords can't be used as identifiers.
Comments
Post a Comment