File tree Expand file tree Collapse file tree 7 files changed +40
-4
lines changed
Expand file tree Collapse file tree 7 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 1- # 11. Print out the sentence from A10 but make the month upper case.
1+ # A11 - Print out the sentence from A10 but make the month upper case.
22
33# Ask the user for input for the month and the temperatures
44month = input ("What month is it?\n " )
Original file line number Diff line number Diff line change 1- # 12. Create a variable that holds your favourite animals and print it out.
1+ # A12 - Create a variable that holds your favourite animals and print it out.
22# Make sure the animals are all on different lines and tabbed.
33
44# Create a list of your favourite animals, using \n\t for the new line and new tab
Original file line number Diff line number Diff line change 1- # 13. Ask the user to enter their name as well as a number.
1+ # A13 - Ask the user to enter their name as well as a number.
22# Print out the uppercase character at that position in the string.
33
44# Ask the user for input
Original file line number Diff line number Diff line change 1+ # A14 - Slice the string with steps of 2, excluding the first and last characters of the string "WelcometoPython"
2+
3+
4+ # creating a variable with the string in
5+ str = "WelcometoPython"
6+
7+ # finding out the length of the string to decide which characters to exclude
8+ print (len (str ))
9+
10+ # slicing the string with steps of 2, excluding the first and last character
11+ print (str [1 :14 :2 ])
Original file line number Diff line number Diff line change 1- # Ask the user to enter their favourite colour and find out the length of the colour they input.
1+ # A8 - Ask the user to enter their favourite colour and find out the length of the colour they input.
22
33# Ask the user for input
44colour = input ("What is your favourite colour?\n " )
Original file line number Diff line number Diff line change 141411 . Print out the above sentence but make the month upper case.
151512 . Create a variable that holds your favourite animals and print it out. Make sure the animals are all on different lines and tabbed.
161613 . Ask the user to enter their name as well as a number. Print out the uppercase character at that position in the string.
17+ 14 . Slice the string with steps of 2, excluding the first and last characters of the string "WelcometoPython"
Original file line number Diff line number Diff line change @@ -351,6 +351,30 @@ print("HeLlO".lower()) # hello
351351
352352---
353353
354+ # Slicing
355+
356+ ---
357+
358+ # Slicing
359+
360+ ```
361+ # slicing from one point to another
362+ "string"[0:6] #string
363+ "string"[1:4] #tri
364+
365+ # slicing from one point to the end
366+ "string"[0:] #string
367+ "string"[1:] #ing
368+
369+ # slicing from the start to another point
370+ "string"[:0] #
371+ "string"[:2] #st
372+
373+ # slicing from the start to end, by skipping step
374+ "string"[0:6:2] #srn
375+ ```
376+ ---
377+
354378# Putting it together
355379
356380``` python
You can’t perform that action at this time.
0 commit comments