p.33(f-string)

Run Settings
LanguagePython
Language Version
Run Command
name="john" age=10 #case 1 place holder codes %s string, %d integer %f flost %x hex #print("Name:%s,Age:%d"%(name,age)) #case 2 convert date to str #print("Name:"+name+",Age" + str(age)) #case 3 str.format() #print("Name:{},Age:{}, name agin:{}",format(name,age)) #case 4 named argument #print("Name:{n},Age:{a},Name again:{n}",format(n=name,a=age)) #eg. #print("Double{x}:{x}+{x}={sum_x}",format(x=5,sum_x=5 +5)) #case 5 :f-string python > 3.6 #print(f"Name:{name},Age:{age},Name agin:{name}") x=5 sum_x=5+5 price=49.99 tax=0.08 total=price*(1+tax) print(f"Price:${price:.2f}|Tax:{tax:.1%}|Total:${total:.2f}") print('1---5----01---5-----0') print(f"{age:5d}")#{varlable:[width][type]} print(f"{'Name':<10}{'Age':>5}") print(f"{name:<10s}{age:>5.2f}") print(f"{'Apple':^10}") print(f"{name:<<10s}{age:->10.2f}")
Editor Settings
Theme
Key bindings
Full width
Lines