Hii @nakuldubey0601
Exactly the same happened with me . This happens because there is a connection error . If you want to check then write
print(data)
Above the line of " sensor value is"
You will see a connection error
This is because the Virtual box is not getting the internet connection properly. Check ur internet connection and update all the packages by the command
Sudo apt-get -y update
And now run the code
I hope this will work.