-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_p.py
57 lines (46 loc) · 1.17 KB
/
python_p.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
# Study Demo
A = 1
B = 2
print(A + B)
# string
from string import digits
print("The digits are", digits)
# math
from math import e
print("The value of e is", e)
# notation
message1 = "what's wrong with me"
message2 = 'He said, What did you do?'
print(message1)
print(message2)
# escape Characters
print("He said, \"What's wrong with me?\" to the girl.")
print("This will\nbe on two lines.")
print("\tThis will\thave some\tgaps.")
# Numbers and String
print(1 + 2)
print("1" + "2")
# String equality
print("Dog" == "Dog")
# String inequality
print("Dog" != "Cat")
# String ordering
print("Aardvark" < "Zoo")
print("Orange" >= "Apple")
# membership in string
# String membership
print("house" in "boathouse")
print("cow" in "cowabunga")
print("y" not in "axes")
print("xe" not in "axes")
# All strings contain the empty string
print("" in "all strings contain the empty string")
# Spaces are characters too
print(" " in "this string contains a space character")
# You can use variables containing string values too
word = "apple"
print(word in "applesauce")
print("p" in word)
print("w" not in word)
person_name = "Grace Hopper"
print(person_name[5]) # Prints the space character!