-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstrings.qs
More file actions
43 lines (32 loc) · 870 Bytes
/
Copy pathstrings.qs
File metadata and controls
43 lines (32 loc) · 870 Bytes
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
# Strings
# You can use single quotes or double quotes.
single = 'hello'
double = "world"
print(single)
print(double)
# + joins strings.
message = single + " " + double
print(message)
# * repeats strings, like Python.
print("ha" * 3)
print(3 * "yo")
# Quotes can appear inside strings when they are not the closing quote.
funny = 'i use ' inside this string.'
print(funny)
# Indexes start at 1.
word = "Quanto"
print("first letter:", word[1])
print("last letter:", word[-1])
# Slices use start:end. The end is included.
print("slice:", word[2:5])
# len() returns the length of a string.
print("length:", len("Quanto"))
# str() converts a value to a string.
print("number as string:", str(42))
# Short assignment works on strings.
greeting = "hello"
greeting += " world"
print(greeting)
# String with escape sequences.
print("line1\nline2")
print("tab\there")