0
0
DSA Pythonprogramming~10 mins

How Strings Work Differently Across Languages in DSA Python - Code Step by Step

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the first character of the string.

DSA Python
first_char = my_string[[1]]
Drag options to blanks, or click blank then click option'
A1
B0
C-1
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 as the first index
Using negative indices incorrectly
2fill in blank
medium

Complete the code to get the substring from index 2 to 5 (exclusive).

DSA Python
substring = my_string[[1]]
Drag options to blanks, or click blank then click option'
A2..5
B2,5
C2:5
D2-5
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or dashes instead of colon
Including the end index character
3fill in blank
hard

Fix the error in the code to concatenate two strings correctly.

DSA Python
full_string = str1 [1] str2
Drag options to blanks, or click blank then click option'
A/
B*
C-
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which repeats strings
Using arithmetic operators like '-' or '/'
4fill in blank
hard

Complete the code to create a dictionary with words as keys and their lengths as values, only for words longer than 3 characters.

DSA Python
lengths = {word: [1] for word in words if len(word) > 3}
Drag options to blanks, or click blank then click option'
Blen(word)
Cword
Dword.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra characters after word for key
Using word instead of len(word) for value
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words shorter than 5 characters.

DSA Python
result = { [1]: [2] for word in words if len(word) [3] 5}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C<
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of upper()
Using > instead of < in condition