import time,math,random
from machine import I2C, SoftI2C, Pin
from pico_i2c_lcd import I2cLcd
i2c = SoftI2C(sda=Pin(0), scl=Pin(1), freq=400000)
lcd_address = i2c.scan()[0]
lcd = I2cLcd(i2c, lcd_address, 2, 16)
# print(lcd_address)
r = random.randint(1, 100)
i = random.randint(1, 100)
# r=1
# i=1
power = math.sqrt(r**2 + i**2)
argument = math.atan2(i, r)
lcd.clear()
lcd.putstr("Complex Number:\n")
lcd.putstr("{0} + {1}i".format(r, i))
time.sleep(2)
lcd.clear()
lcd.putstr("Power: {:.2f}\n".format(power))
lcd.putstr("Argument: {:.2f}".format(argument))
time.sleep(10)
lcd.clear()