If im not wrong, is B)
string=str(1/3) ---- this is equal a 0.3333333333
dummy=''
>>> for character in string:
dummy=character+dummy
>>> dummy
'3333333333333333.0'
print(dummy[-1])----- this is 0
dummy = character + dummy: Adds the current character to the BEGINNING of the dummy string, effectively reversing the order of characters.
print(dummy[-1]): Prints the last character of the reversed string, which is the first character of the original string.
It outputs 0.
string=str(1/3)
print("string=",string)
dummy=''
for character in string:
print("character=",character)
dummy=character+dummy
print("dummy=",dummy)
print(dummy[-1])
Answer is B:
string = str(1/3)
dummy = ''
for character in string:
dummy = dummy + character
print(dummy[-1]) # 3
# In python all types are classses
print(type(dummy)) # <class 'str'>
If there is: for character in strong: Answer is A
If there is: for character in string: Answer is B
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Efren
Highly Voted 3 years agozantrz
Most Recent 9 months, 4 weeks agoseaverick
10 months agoCC_DC
1 year, 4 months agokontra
1 year, 6 months agoSiva_2022
2 years, 6 months agomacxsz
2 years, 6 months agoDTL001
2 years, 11 months agogrinha
2 years, 8 months agoTon123
2 years, 8 months agolukaki
3 years ago