Write a program that takes an input of a random string and prints the first character of the input string as output to the console.
Input Format
Single line input of a random string
Output Format
Print the single character to the console.
Sample Input 1
Hello
Sample Output 1
H
Sample Output 2
World
Sample Output 2
W
Find the last character
Task
Write a program that takes an input of a random string and prints the last character of the input string as output to the console.
Input Format
Single line input of a random string
Output Format
Print the single character to the console.
Sample Input 1
Hello
Sample Output 1
o
Sample Output 2
World
Sample Output 2
d
String Slicing
Task
Write a program that takes a four-line input and maps them to the variables sample_string, start_index, end_index, and jump_value respectively. Print the substring from the original string based on the values of start_index, end_index, and jump_value.
Input Format
The first line contains a random string
The second line contains a random integer
The third line contains a random integer
The fourth line contains a random integer
Output Format
Single line containing the substring
Sample Input 1
Hello, World!
0
5
1
Sample Output 1
Hello
Sample Input 2
I love coding
2
14
2
Sample Output 2
lv oig
Append in List
Task
Write a program that takes an input of a random string, adds it to the end of the pre-existing list, and prints the updated list to the console.
Input Format
Single line input, as a random string
Output Format
Print the updated list
Sample Input 1
Jenny
Sample Output 1
['John', 'Kim', 'Kevin', 'Rose', 'Jenny']
Sample Input 2
Peter
Sample Output 2
['John', 'Kim', 'Kevin', 'Rose', 'Peter']
Remove in List
Task
Write a program that takes a random number (N) as input, removes the value at the N index in a pre-existing list, and prints the updated list to the console.
Input Format
Single line input of a random integer
Output Format
Print the updated list
Sample Input 1
4
Sample Output 1
['John', 'Kim', 'Kevin', 'Rose']
Sample Input 2
1
Sample Output 2
['John', 'Kevin', 'Rose', 'Rohan']
Practice Questions -
Basic data types will be discussed in the following notebook.
Number
Boolean
String
String Methods
Type conversion
Variable File:
Variables.ipynb
12.2 kB
Operators File:
Operators.ipynb
34.8 kB
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (