-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd.py
More file actions
80 lines (70 loc) · 2.01 KB
/
Copy pathd.py
File metadata and controls
80 lines (70 loc) · 2.01 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
69
70
71
72
73
74
75
76
77
78
79
80
#repitation
message = "python "
print(message * 3)
#repitation
message = "python "*2
print(message)
#string methods
word = "prOgrAmmIng"
sen = " python programming "
print(word.upper())
print(word.lower())
print(sen.strip())
print(sen.replace("python","C"))
#string operation with quotes
a = "chandan said 'hi'"
print(a)
b = 'chandan said "hi"'
print(b)
c = "chandan said 'hi' darshan said 'hello' "
print(c)
# for multi-line string use triple qoutes compulsary ''' ''' or """ """
d = """a said 'b'
b said 'c' """
print(d)
e = "e said 'f'\nf said 'g' "
print(e)
x ="x said '''y''' y said 'z' "
print(x)
q = """p said 'r'
k said "v" """
print(q)
# length of string
a = "GOOD MORNING"
print(len(a))
#accessing single string characters
c = "chandan"
print(c[4]) # index = position - 1
print(c[2])
print(c[-2])
#accessing substrings
c ="chandan"
print(c[2:7])
print(c[:3])
print(c[2:5])
print(c[-4:-1])
print(c[-1:-4]) # output will be empty string because by default it will take +1 and tries to move forward but after -1 there is ntg so empty string will be a output
print(c[-1:-4:-1])
print(c[::2])
print(c[::3])
print(c[::-1])
print(c[::-2])
print(c[:6:2])
print(c[1:5:3])
print(c[-1:])
print(c[-5:-1:2])
#small project from engineering in kannada 3b notes
senten = input('sen = jdjd ') # here "sen = jdjd" basically a prompt. In the context of input(), a prompt is any msg displayed to the user asking them to enter input. but remember not every msg displayed by a program is a prompt ex: print("welcome") welcome is an output, not a prompt
print(senten.upper())
print(senten.lower())
print(senten)
print(senten.replace(" ","_"))
print(senten.strip())
# see here "jdjd" is not converting into upper() lower() and all because variable takes only user input for processing not prompt
# small project
xyz = input("text = ")
pqr=(xyz.replace(" ",""))
print(len(pqr))
# escape sequence
print("hello\n\twrold")
print ("this is a blacklash : \\")