a=list(map(int,input().split())) x=str(a[0]/a[1]) x=list(x) for i in range(10000): x.append("0") print("".join(x[2+a[2]-1:2+a[2]+3-1]))
时间: 2024-05-19 14:11:19 浏览: 56
Python期末试题A.docx
This code takes three integers as input and prints a specific digit of their quotient.
First, it reads the input integers and calculates their quotient using integer division (//) and converts it to a string. Then, it converts the quotient string to a list of characters and appends 10000 "0"s to the end of the list using a for loop.
Finally, it uses slicing to extract a specific range of characters from the list, which corresponds to the desired digit of the quotient. The range is determined by multiplying the third input integer by 2 (to get the starting index of the range) and subtracting 1, and by multiplying the third input integer by 2 and adding 3 and subtracting 1 (to get the ending index of the range).
However, there are some syntax errors in the code, specifically on the line where the range is extracted. The correct code should be:
a = list(map(int,input().split()))
x = str(a[0]//a[1])
x = list(x)
for i in range(10000):
x.append("0")
print("".join(x[a[2]*2-1:a[2]*2+3-1]))
阅读全文