Introduction - Python manual excercies loops
Introduction - Python manual excercies loops
2. Script file:
- You can create file with .py extension.
- python filename.py
Comments:
- Explain the code
- Only for developer's knowledge
syntax:
#comment
Variable (Identifier):
- Store value
- Refers to memory location in RAM
- Don't need to specify type of variable.
- Number - don't use double quotation sign
- String - double quotation
python:
age=18
price=19.99
name="krunal"
Rules of variable:
- The first character of the variable must be an alphabet or underscore(_).
- All the characters except the first character may be an alphabet of lower-case(a-
z), upper-case (A-Z), underscore or digit (0-9).
- Identifier name must not contain any white-space, or special character (!, @, #,
%, ^, &, *).
- Identifier name must not be similar to any keyword defined in the language.
- Identifier names are case sensitive for example myname, and MyName is not the
same.
Variable Assignments:
#Assign single value to single variable
firstNumber = 20
print(firstNumber)
print string and integer value together: (concatenate value, join two values)
age = 20
print("alex's age: ",age)
price = 699.99
print("Apple Watch Series 7 Price: " , price)
print("Age: ",gabiAge)
#Assign multiple values to multiple variables
a,b,c=10,20.99,"hello"
print(c)
Example: Variable has same value then you can concate(join) two values.
firstName = "krunal"
lastName = "sukhwani"
name = firstName + lastName
print(name)
shoesPrice = 100
watchPrice = 299.99
total = shoesPrice + watchPrice
print(total)
Error:
productName = "ipad"
productPrice = 1299.99
productInfo = productName + productPrice
print(productInfo)