Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Binary-strings/Python/binary-strings-1.py
Normal file
5
Task/Binary-strings/Python/binary-strings-1.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
s1 = "A 'string' literal \n"
|
||||
s2 = 'You may use any of \' or " as delimiter'
|
||||
s3 = """This text
|
||||
goes over several lines
|
||||
up to the closing triple quote"""
|
||||
5
Task/Binary-strings/Python/binary-strings-10.py
Normal file
5
Task/Binary-strings/Python/binary-strings-10.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
items = ["Smith", "John", "417 Evergreen Av", "Chimichurri", "481-3172"]
|
||||
joined = ",".join(items)
|
||||
print joined
|
||||
# output:
|
||||
# Smith,John,417 Evergreen Av,Chimichurri,481-3172
|
||||
5
Task/Binary-strings/Python/binary-strings-11.py
Normal file
5
Task/Binary-strings/Python/binary-strings-11.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
line = "Smith,John,417 Evergreen Av,Chimichurri,481-3172"
|
||||
fields = line.split(',')
|
||||
print fields
|
||||
# output:
|
||||
# ['Smith', 'John', '417 Evergreen Av', 'Chimichurri', '481-3172']
|
||||
5
Task/Binary-strings/Python/binary-strings-12.py
Normal file
5
Task/Binary-strings/Python/binary-strings-12.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
s1 = b"A 'byte string' literal \n"
|
||||
s2 = b'You may use any of \' or " as delimiter'
|
||||
s3 = b"""This text
|
||||
goes over several lines
|
||||
up to the closing triple quote"""
|
||||
2
Task/Binary-strings/Python/binary-strings-13.py
Normal file
2
Task/Binary-strings/Python/binary-strings-13.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
x = b'abc'
|
||||
x[0] # evaluates to 97
|
||||
3
Task/Binary-strings/Python/binary-strings-14.py
Normal file
3
Task/Binary-strings/Python/binary-strings-14.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x = b'abc'
|
||||
list(x) # evaluates to [97, 98, 99]
|
||||
bytes([97, 98, 99]) # evaluates to b'abc'
|
||||
3
Task/Binary-strings/Python/binary-strings-2.py
Normal file
3
Task/Binary-strings/Python/binary-strings-2.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s = "Hello "
|
||||
t = "world!"
|
||||
u = s + t # + concatenates
|
||||
4
Task/Binary-strings/Python/binary-strings-3.py
Normal file
4
Task/Binary-strings/Python/binary-strings-3.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
assert "Hello" == 'Hello'
|
||||
assert '\t' == '\x09'
|
||||
assert "one" < "two"
|
||||
assert "two" >= "three"
|
||||
2
Task/Binary-strings/Python/binary-strings-4.py
Normal file
2
Task/Binary-strings/Python/binary-strings-4.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if x=='': print "Empty string"
|
||||
if not x: print "Empty string, provided you know x is a string"
|
||||
3
Task/Binary-strings/Python/binary-strings-5.py
Normal file
3
Task/Binary-strings/Python/binary-strings-5.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
txt = "Some text"
|
||||
txt += '\x07'
|
||||
# txt refers now to a new string having "Some text\x07"
|
||||
6
Task/Binary-strings/Python/binary-strings-6.py
Normal file
6
Task/Binary-strings/Python/binary-strings-6.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
txt = "Some more text"
|
||||
assert txt[4] == " "
|
||||
assert txt[0:4] == "Some"
|
||||
assert txt[:4] == "Some" # you can omit the starting index if 0
|
||||
assert txt[5:9] == "more"
|
||||
assert txt[5:] == "more text" # omitting the second index means "to the end"
|
||||
3
Task/Binary-strings/Python/binary-strings-7.py
Normal file
3
Task/Binary-strings/Python/binary-strings-7.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
txt = "Some more text"
|
||||
assert txt[-1] == "t"
|
||||
assert txt[-4:] == "text"
|
||||
3
Task/Binary-strings/Python/binary-strings-8.py
Normal file
3
Task/Binary-strings/Python/binary-strings-8.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
v1 = "hello world"
|
||||
v2 = v1.replace("l", "L")
|
||||
print v2 # prints heLLo worLd
|
||||
3
Task/Binary-strings/Python/binary-strings-9.py
Normal file
3
Task/Binary-strings/Python/binary-strings-9.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
v1 = "hello"
|
||||
v2 = "world"
|
||||
msg = v1 + " " + v2
|
||||
Loading…
Add table
Add a link
Reference in a new issue