what we use in python to fact ip is a module called socket
import socket
next use inside method
computer_name = socket.gethostname()
next create a one more getip variable to fact a ip form hostanme
getip= socket.gethostbyname(computer_name)
then use print and get your ip
print( "computer name: " + computer_name )
print("my ip is : " + getip)
full structure of code
get a full code from my github repositorie
https://github.com/santyadavcoder/ip-address-fact-in-python