File tree Expand file tree Collapse file tree 2 files changed +52
-3
lines changed Expand file tree Collapse file tree 2 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 1
1
# A14 - Slice the string with steps of 2, excluding the first and last characters of the string "WelcometoPython"
2
2
3
-
4
- # creating a variable with the string in
3
+ # creating a variable with the string in
5
4
str = "WelcometoPython"
6
5
7
- # finding out the length of the string to decide which characters to exclude
6
+ # finding out the length of the string to decide which characters to exclude
8
7
print (len (str ))
9
8
10
9
# slicing the string with steps of 2, excluding the first and last character
Original file line number Diff line number Diff line change
1
+ width = 4
2
+ height = 3
3
+ area = width * height
4
+ print ("Rectangle of width " + str (width ) + " and height " + str (height ) + " has an area of " + str (area ))
5
+
6
+ string = "python"
7
+ print (len (string ))
8
+
9
+ print (string [0 ])
10
+ print (string [2 ])
11
+
12
+ name = input ("What's your name? " )
13
+ print ("Hello " + name )
14
+
15
+ age = int (input ("How old are you? " ))
16
+ adjusted_age = age + 15
17
+ print ("In 15 years, you will be " + str (adjusted_age ))
18
+
19
+ print ("Hello " + name + ", you are currently " + str (age ) + " years old. In 15 years time you will be " + str (adjusted_age ) + "." )
20
+
21
+ hometown = input ("What's your hometown? " )
22
+ print (hometown .upper ())
23
+
24
+ fav_color = input ("What's your favourite color? " )
25
+ print (len (fav_color ))
26
+
27
+ month = input ("What month is it? " )
28
+ weather = input ("How hot is it today? " )
29
+ print ("It is " + month + " and it is " + weather + "C today" )
30
+
31
+ temp1 = int (input ("What's the weather on Monday? " ))
32
+ temp2 = int (input ("What's the weather on Tuesday? " ))
33
+ temp3 = int (input ("What's the weather on Wednesday? " ))
34
+ temp4 = int (input ("What's the weather on Thursday? " ))
35
+ temp5 = int (input ("What's the weather on Friday? " ))
36
+
37
+ average_temp = (temp1 + temp2 + temp3 + temp4 + temp5 )/ 5
38
+ print ("It is " + month + " and the average temperature is " + str (average_temp ) + " degrees celsius" )
39
+
40
+ print ("It is " + month .upper () + " and the average temperature is " + str (average_temp ) + " degrees celsius" )
41
+
42
+ favourite_animals = "dog\n \t cat\n \t fish\n \t chicken\n \t goat"
43
+ print (favourite_animals )
44
+
45
+ number = int (input ("Pick a number between 0 and " + str (len (name ) - 1 ) + "? " ))
46
+ print (name [number ].upper ())
47
+
48
+ str = "WelcometoPython"
49
+ print (str [1 :- 1 :2 ])
50
+
You can’t perform that action at this time.
0 commit comments