forked from Jaish19/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.string.py
57 lines (55 loc) · 1.23 KB
/
3.string.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
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x="jaish gamb"
>>> type(x)
<type 'str'>
>>> x='jaish gamb'
>>> type(x)
<type 'str'>
>>> x='I don't wanna play this game'
SyntaxError: invalid syntax
>>> x="I don't wanna play this game"
>>> x
"I don't wanna play this game"
>>> print(x)
I don't wanna play this game
>>> y='he asking me "wru?"'
>>> y
'he asking me "wru?"'
>>> x='I don\'t wanna play this game'
>>> x
"I don't wanna play this game"
>>> print('c:\desktop\nextvideo')
c:\desktop
extvideo
>>> print(r'c:\desktop\nextvideo')
c:\desktop\nextvideo
>>> first='jai'
>>> second='ganesh'
>>> first+second
'jaiganesh'
>>> first*5
'jaijaijaijaijai'
>>> first*2
'jaijai'
>>> first**2
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
first**2
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
>>> num=55
>>> first='jaish'
>>> first+num
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
first+num
TypeError: cannot concatenate 'str' and 'int' objects
>>> first+str(num)
'jaish55'
>>> num='55'
>>> first+num
'jaish55'
>>> num=55
>>> first+'num'
'jaishnum'
>>>