-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables
44 lines (40 loc) · 842 Bytes
/
variables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#test with strings
string1 = str("test")
string2 = string1
string2 = "test2"
print(string1)
print(string2)
print(id(string1)) #object1
print(id(string2)) #object2
#test with float
float1 = 3.1234
float2 = float1
float2 = 4.4354
print(float1)
print(float2)
print(id(float1)) #object1
print(id(float2)) #object2
#test with int
int1 = 3
int2 = int1
int2 = 4
print(int1)
print(int2)
print(id(int1)) #object1
print(id(int2)) #object2
#test with list
mylist1 = ["apple", "banana", "cherry"]
mylist2 = mylist1
mylist2[0] = "peanut"
print(mylist1)
print(mylist2)
print(id(mylist1)) #object1
print(id(mylist2)) #object1
mytuple1 = ("apple", "banana", "cherry")
mytuple2 = mytuple1
#mytuple2[0]="peanut" #breaks !!!
mytuple2 = ("peanut", "banana", "cherry")
print(mytuple1)
print(mytuple2)
print(id(mytuple1)) #object1
print(id(mytuple2)) #object2