Repository navigation
Expand file tree
/
Copy pathhelloworld.py
More file actions
63 lines (51 loc) · 1.46 KB
/
Copy pathhelloworld.py
File metadata and controls
63 lines (51 loc) · 1.46 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
print('hello')
print("hello" + "hello")
greeting = "hello"
name ="1"
print(greeting + ' ' + name) #gives error for int
g=input("Enter name ")
print(greeting + ' ' + g) #gives error for int
#escape charecters
splitString = "This spring has been\nsplit\nsplit"
print(splitString)
tabbedString ="1\t2\t3\t4"
print(tabbedString)
#writing special characters
print('The pet shop owner said "No, no \'e\'s uh,...he\'s resting".')
print("The pet shop owner said \"No, no 'e's uh,...he's resting\".")
print("""The pet shop owner said "No, no 'e's uh,...he's resting".""")
another="""s
d
d
d"""
print(another)
another="""s
d\
d\
d"""
print(another)
print(12//4) #integer rounded
z ="pyhton"
print(z[3])
print(z[0:4])
print(z[0:6:2]) #in steps of 2 excludes 6
number ="9,226,456,456,565,555"
print(number[1::4])#starts with 1st value and slices every 4th character
#slicing backwards
letters="wedewfregrgtrhthth"
print(letters[10:0:-1])#reverse order except 1, b[::-1} this does it
print(letters[:-9:-1]) #last 8 in reverse order
print(z[-4:]) #last4 values
print("a" *5)
print("There are {0} days in {1}, {2}, {3}".format(31, "Jan", "Mar", "Feb"))
f ="friday"
print("day" in f)
print("hi" in f)
age=24
print("age is {0} years".format(age))
for i in range(1,13):
print("NO {0} is sqred and no {1} is cube". format(i**2, i**3))
age =2
print(name+f" is {age} years old")
days = "Mon, Tue, Wed, Thu, Fri, Sat, Sun"
print(days[::5])