-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9. String
More file actions
68 lines (64 loc) · 1.43 KB
/
9. String
File metadata and controls
68 lines (64 loc) · 1.43 KB
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
58
59
60
61
62
63
64
65
66
67
68
>>> var1=100
>>> var2=11.11
>>> var3=2+3j
>>> var4=True
>>> type(var1)
<class 'int'>
>>> type(var2)
<class 'float'>
>>> type(var3)
<class 'complex'>
>>> type(var4)
<class 'bool'>
>>> var5='a'
>>> var6='z' #C/C++/java/C# its character but in python 'a' "a"--it is python string <class,str>
>>> var7="a"
>>> var8='a"
SyntaxError: EOL while scanning string literal
>>> var8="a"
>>> var9='sushil kumar patel'
>>> var10="sushil kumar patel"
>>> type(var5)
<class 'str'>
>>> type(var6)
<class 'str'>
>>> type(var7)
<class 'str'>
>>> type(var8)
<class 'str'>
>>> type(var9)
<class 'str'>
>>> type(var10)
<class 'str'>
>>> var11=''' sushil kumar patel '''
>>> var12=""" sushil kumar patel """
>>> type(var11)
<class 'str'>
>>> type(var12)
<class 'str'>
>>>
constant/literals
number system in python
binary '0b1101111' 0b(prefix)
octal '0o157' 0o(prefix)
hexa '0x6f' 0x(prefix)
decimal 111
Integer
binary '0b1101111' 0b(prefix)
octal '0o157' 0o(prefix)
hexa '0x6f' 0x(prefix)
decimal 111
float
11.11
complex
2+2j(complex)
string
def: string its group of zero of more character C/C++/java
** python---zero or more character
' '
"" ""
'a'
'abc'
>>> var=''
>>> type(var)
<class 'str'>