|
1 |
| -# PYTHON STRINGS |
2 |
| ->## Answer each question with a code solution. |
3 |
| -1. Create a string and print it. |
4 |
| -1. Take a string input and print it's length. |
5 |
| -1. Print the last word of the string `Python is great` using slices. |
6 |
| -1. Print the each word in different line of string `python is everywhere`. |
7 |
| -1. Print the string `Hello World!` in reverse. |
8 |
| -1. Convert the string `How are you?` in uppercase. |
9 |
| -1. Convert the string `How Is It Going?` in lowercase. |
10 |
| -1. Join the following list by spaces(` `) and print the result. |
11 |
| - ```py |
12 |
| - words = ['Python', 'is', 'easy', 'to', 'learn'] |
13 |
| - ``` |
14 |
| -1. Print a multiline string using a single `print` |
15 |
| -1. Print this string `to move to newline '\n' is used.` (results should look exactly like the provided string) |
16 |
| -1. Print a variable with some text using a single print function, output should look like following. |
17 |
| - ``` |
18 |
| - the variable is 15 |
19 |
| - ``` |
20 |
| -1. concatenate the following strings and print the result |
21 |
| - ```py |
22 |
| - s1 = 'python ' |
23 |
| - s2 = 'is ' |
24 |
| - s3 = 'great.' |
25 |
| - ``` |
26 |
| -1. Print `#` 20 times without using a loop |
27 |
| -1. Print numbers from 1 to 9, each on a seperate line, followed by a dot, output should look like the following- |
28 |
| - ``` |
29 |
| - 1. |
30 |
| - 2. |
31 |
| - 3. |
32 |
| - |
33 |
| - ``` |
34 |
| -1. Ask user to input a sentence and print each word on a different line. |
35 |
| -1. Ask user to input a string and check if the string ends with '?' |
36 |
| -1. Ask user to input a string and print how many times `e` appeared in the string |
37 |
| -1. Check if the user input is a number. |
38 |
| -1. Remove the extra spaces in beginning and in the end of the following string- |
39 |
| - ```py |
40 |
| - text = ' this is not a good string ' |
41 |
| - ``` |
42 |
| -1. Ask user to input string, print `found` if any of the character is upper case. |
43 |
| -1. Extract names from the following string and store them in a list. |
44 |
| - ```py |
45 |
| - names = 'Joe, David, Mark, Tom, Chris, Robert' |
46 |
| - ``` |
47 |
| -1. In the following string, add `aye` in the end of every word and print the results. |
48 |
| - ```py |
49 |
| - text = 'this is some text' |
50 |
| - ``` |
51 |
| -1. ask user to enter a string and check if the string contains `fyi` |
52 |
| -1. Remove all the special characters and numbers from the following string |
53 |
| - ```py |
54 |
| - text = '%p34@y!*-*!t68h#&on404' |
55 |
| - ``` |
56 |
| -1. calculate the average word length of the following paragraph. |
57 |
| - ``` |
58 |
| - this is a paragraph which is written just for the purpose of providing content to let the average word length be calculated |
59 |
| - ``` |
| 1 | +Practice questions for python students |
0 commit comments