You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-121Lines changed: 2 additions & 121 deletions
Original file line number
Diff line number
Diff line change
@@ -53,124 +53,5 @@ Python has an array of frameworks for developing websites. The popular framewor
53
53
* path?
54
54
* In order to execute these files( javac java python (command names)), it must locate these files in path environment variables
55
55
56
-
## Variables
57
-
58
-
* Variables are containers for storing data values.
59
-
* Unlike other programming languages, Python has no command for declaring a variable.
60
-
* A variable is created the moment you first assign a value to it
61
-
62
-
Example :
63
-
```python
64
-
x =1234
65
-
y ="Aman"
66
-
print(x)
67
-
print(y)
68
-
```
69
-
70
-
Variables do not need to be declared with any particular type and can even change type after they have been set.
71
-
72
-
```
73
-
x = 78
74
-
x = "Illona"
75
-
print(x)
76
-
```
77
-
78
-
String variables can be declared either by using single or double quotes:
79
-
80
-
```
81
-
x = "Aman" // is the same as
82
-
x = 'Aman'
83
-
```
84
-
85
-
_Variable Names_
86
-
87
-
88
-
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). Rules for Python variables:
89
-
* A variable name must start with a letter or the underscore character
90
-
* A variable name cannot start with a number
91
-
* A variable name can only contain alpha-numeric characters and underscores (A-z,0-9,and _)
92
-
* Variable names are case-sensitive (age, Age and AGE are three different variables)
93
-
94
-
95
-
_Assign Value to Multiple Variables_
96
-
Python allows you to assign values to multiple variables in one line:
97
-
98
-
Example
99
-
100
-
```
101
-
x, y, z = "X", "Y", 5
102
-
print(x)
103
-
print(y)
104
-
print(z)
105
-
```
106
-
107
-
And you can assign the same value to multiple variables in one line:
108
-
109
-
```
110
-
Example
111
-
x = y = z = "O"
112
-
print(x)
113
-
print(y)
114
-
print(z)
115
-
```
116
-
117
-
The Python print statement is often used to output variables.
118
-
119
-
* To combine both text and a variable, Python uses the + character:
120
-
121
-
```
122
-
x = "A"
123
-
print("Python is " + x)
124
-
```
125
-
126
-
* You can also use the + character to add a variable to another variable:
127
-
128
-
```
129
-
x = "life is "
130
-
y = "awesome"
131
-
z = x + y
132
-
print(z)
133
-
```
134
-
135
-
* For numbers, the + character works as a mathematical operator:
136
-
```
137
-
x = 78
138
-
y = 98
139
-
print(x + y)
140
-
```
141
-
* If you try to combine a string and a number, Python will give you an error:
142
-
143
-
```
144
-
x = 20
145
-
y = "Aman"
146
-
print(x + y)
147
-
```
148
-
## Global Variables
149
-
150
-
A variable declared outside of the function or in global scope is known as global variable. This means, global variable can be accessed inside or outside of the function.
151
-
152
-
```
153
-
x = "aman"
154
-
def func():
155
-
print("Python is " + x)
156
-
157
-
func()
158
-
```
159
-
## Standard data types
160
-
161
-
Built-in Data Types
162
-
In programming, data type is an important concept.
163
-
164
-
Variables can store data of different types, and different types can do different things.
165
-
166
-
Python has the following data types built-in by default, in these categories:
0 commit comments