-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2 slicing.py
More file actions
92 lines (86 loc) · 2.5 KB
/
Copy path2 slicing.py
File metadata and controls
92 lines (86 loc) · 2.5 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
81
82
83
84
85
86
87
88
89
90
91
92
print ( 'Hello world ')
#String Variables '\t' (tab)
name = "John"
surname = "Smith's Bookshop"
print (name , surname)
print (name + surname) # concatenate
print (name + ' ' + surname) # concatenate
print (name + "\t\t\t" + surname)
print (name + '\n' + surname)
name=10
#
#
##More Printing
x = 'John'
print (x)
print (x)
print (x)
print (x, end=" ")
print (x, end=" ")
print (x, end=" ")
print (x)
print (x)
print (x, end=": ")
print (x, end="---")
print (x)
#
strVar = 'apple'
print (strVar[0])
print (strVar[1])
print (strVar[2])
print (strVar[3])
print (strVar[4])
# 01234567890
strVar = 'Hello World!'
print (strVar ) # Prints complete string
print (strVar[0]) # Prints first character of the string
print (strVar[2:8]) # Prints characters starting from
print (strVar[2:] ) # Prints string starting from 3rd character
print (strVar * 3) # Prints string times
print (strVar + "TEST") # Prints concatenated string
print (strVar[-1:])
print (strVar[-5:]) # Prints last five string
print (strVar[-5:-1])
print (strVar[-5:-2])
#
#
name = 'John'
print (name, type(name))
name = 10
print (name, type(name))
#### collect input from end-user
name = input ( 'What is your name ' )
print (name, type(name))
#moviename = "The Terminator 2"
# get user input
moviename = input ( 'Which movie would you like to see? ')
adults = input ('How many adults? ')
children = int( input ('How many children tickets would you like to buy? '))
pensioners = int (input ('How many pensioner tickets would you like to buy? '))
adults = int(adults)
tp = 10
print ('Movie name:', moviename)
print ('Ticket price:' , tp)
print ('Adults:', adults)
print ('Children:',children)
print ('Pensioners:', pensioners)
totalPrice = tp*adults + (tp/2*children ) + (tp/3*pensioners)
print ('Total Price', totalPrice)
### cast string input to numbers
adults = int ( adults )
children = int ( children )
pensioners = int (pensioners)
# calculations
price = 10
totalprice = ( int(adults) * price )
totalprice = totalprice + ( int(children) * price / 2 )
totalprice = totalprice + ( int( pensioners) * price * 0.3)
#### give output of results to the end user
print ("")
print (name)
print ("You have ordered:")
print ("Movie:", moviename)
print ("Number of adult tickets:", adults)
print ("Number of children tickets:", children)
print ("Number of pensioners tickets:", pensioners)
print ("Please pay:", totalprice )