Answer:
#part 1.
#declare and initialize string variable word
word="welcome"
# extract the last 3 characters of the string and print
print("last 3 characters of word is: ",word[-3:])
#part 2.
#declare and initialize string variables
firstName="John"
middleName="Fitzgerald"
lastName="Kennedy"
#print the initials of all names
print("initials of name is: ",firstName[0]+middleName[0]+lastName[0])
#part 3.
#declare and initialize profit and loss
profits=10
losses=10
# if will be true only when profits equals to losses
if profits==losses:
print("both are equal")
Explanation:
In part 1, declare and initialize string variable word with "welcome" then extract last 3 characters of the string and print it. In part 2, declare and initialize names variable then find the first character of each name that is character at 0 index. Append all 3 and print that value. In part 3, declare and initialize profits with 10 and losses with 10. In the if condition, it will print "both are equal" if both values are equal.
Output:
last 3 characters of word is: ome
initials of name is: JFK
both are equal