Python 3 (not java) 1.Assume that word is a variable of type String that has bee
ID: 3843806 • Letter: P
Question
Python 3 (not java)
1.Assume that word is a variable of type String that has been assigned a value. Write an expression whose value is a String consisting of the last three characters of the value of word. So if the value of word were "biggest" the expression's value would be "est".
2.Given three String variables that have been given values, firstName, middleName, and lastName, write an expression whose value is the initials of the three names: the first letter of each, joined together. So if firstName, middleName, and lastName, had the values "John", "Fitzgerald", and "Kennedy", the expression's value would be JFK". Alternatively, if firstName, middleName, and lastName, had the values "Franklin", "Delano", and "Roosevelt", the expression's value would be "FDR".
3.Write an expression that evaluates to True if and only if the variables profits and losses are exactly equal.
Explanation / Answer
Hello ,
I am providing you expression in python and you can try them in code. The bold part in answer is your expression which you are looking for.
1.) word = "biggest"
value= word[len(word)-3:]
print(value)
We are using slicing method of python here.
2,) firstName ="John"
middleName= "Fitzgerald"
lastName="Kennedy"
value2= firstName[0]+middleName[0]+lastName[0]
print(value2)
3.
def meth():
profit = 5.0
loss = 5.0
if profit == loss:
return True
else:
return False
print(meth())
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.