MySQL using Python: I need a Python code that will run the following script: Wha
ID: 3690009 • Letter: M
Question
MySQL using Python: I need a Python code that will run the following script:
What is the value of ? 10
Congratulations, your answer is correct.
1 out of 1 correct, continue ? (y/n) y
1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
Select the character for 5 : 5
Congratulations, your answer is correct.
2 out of 2 correct, continue ? (y/n) y
What is the value of ? 8
Wrong, the correct answer is 9.
2 out of 3 correct, continue ? (y/n) y
1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
Select the character for 5 : 10
Wrong, the correct answer is at selection 2.
2 out of 4 correct, continue ? (y/n) n
Answered 2 out of 4 correctly.
1 ’u4e00’
2 ’u4e8c’
3 ’u4e09’
4 ’u56db’
5 ’u4e94’
6 ’u516d’
7 ’u4e03’
8 ’u516b’
9 ’u4e5d’
10 ’u5341’
Explanation / Answer
import sys
s1=u'u4e00'.encode('utf-8').strip()
s2=u'u4e8c'.encode('utf-8').strip()
s3=u'u4e09'.encode('utf-8').strip()
s4=u'u56db'.encode('utf-8').strip()
s5=u'u4e94'.encode('utf-8').strip()
s6=u'u516d'.encode('utf-8').strip()
s7=u'u4e03'.encode('utf-8').strip()
s8=u'u516b'.encode('utf-8').strip()
s9=u'u4e5d'.encode('utf-8').strip()
s10=u'u5341'.encode('utf-8').strip()
s=0
print "What is the value of ",s10," ?"
i = input("")
if(i==10):
s=s+1
c=raw_input("%d out of 1 correct, continue ? (y/n)"%(s))
if(c=='n'):
print "Answered %d out of 1 correctly."%(s)
sys.exit()
print "1: %s 2: %s 3: %s 4: %s 5: %s 6: %s 7: %s 8: %s 9: %s 10: %s"%(s4,s2,s9,s7,s5,s8,s10,s3,s1,s6)
i = input("Select the character for 5 :")
if(i==5):
s=s+1;
print "Congratulations, your answer is correct."
else:
print "Wrong, the correct answer is 5."
c=raw_input("%d out of 2 correct, continue ? (y/n)"%(s))
if(c=='n'):
print "Answered %d out of 2 correctly."%(s)
sys.exit()
i = input("What is the value of %s ?"%(s9))
if(i==9):
s = s+1
print "Congratulations, your answer is correct."
else:
print "Wrong, the correct answer is 9."
c=raw_input("%d out of 3 correct, continue ? (y/n)"%(s))
if(c=='n'):
print "Answered %d out of 3 correctly."%(s)
sys.exit()
print "1: %s 2: %s 3: %s 4: %s 5: %s 6: %s 7: %s 8: %s 9: %s 10: %s"%(s10,s5,s9,s7,s3,s4,s1,s2,s6,s8)
i = input("Select the character for 5 :")
if(i==2):
s=s+1;
print "Congratulations, your answer is correct."
else:
print "Wrong, the correct answer is 2."
c=raw_input("%d out of 4 correct, continue ? (y/n)"%(s))
if(c=='n'):
print "Answered %d out of 4 correctly."%(s)
sys.exit()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.