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
...
This section is not available anymore. Please use the main Exam Page.PCAP Exam Questions
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, 7 months agozantrz
Most Recent 1 year, 5 months agoseaverick
1 year, 5 months agoCC_DC
1 year, 11 months agokontra
2 years, 1 month agoSiva_2022
3 years, 1 month agomacxsz
3 years, 2 months agoDTL001
3 years, 6 months agogrinha
3 years, 3 months agoTon123
3 years, 3 months agolukaki
3 years, 7 months ago