8-April-2026 Self-Practices

Run Settings
LanguagePython
Language Version
Run Command
#temp 3 name = "john" age = 10 # case 1 place holder codes %s string, %d integer %f float %x hex print("Name : %s, Age : %s" % (name, age)) print("Name : %s, Age : %d" % (name, age)) # case 2 convert data to str print("Name : " + name +", Age : " + str(age)) # case 3 str.format() print("Name : {}, Age : {}, Name again : {}".format(name, age, name)) # case 4 named arguments 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 again : {name}") x = 5 sum_x = 5+5 print(f"Double {5}: {5} + {5} = {5+5}") print(f"Double {x}: {x} + {x} = {sum_x}") #temp 4 #format numbers price = 49.99 tax = 0.08 total = price * (1 + tax) print(f"Price : ${price:.2f} | Tax : {tax:.1%} | Total: ${total:.2f}") ## f"{variable:[fill][align][width][.precision][type]} print(f"{age:5d}") print('1---5----01---5----0') print(f"{'Name':<10}{'Age':>5}") # < left align, > right align ^ center #print(f"{name:$<10}{age:->5.2f}") print(f"{name:<10}{age:->5.2f}") print(f"{name:<10}{age:->5d}") print(f"{name:<10}{age:->10.2f}") print(f"{name:<<10s}{age:->10.2f}{' ':$<10}") print(f"{'Apple':^10}") #1---5----01---5----0 #Name Age #john 10 # Apple print(f"{42:05}") print(f"{42:0<5}") print(f"{1234567:,}") print(f"{42:5b}") # binary value print(f"{42:5o}") # octal value print(f"{42:5x}") # hex value # scu firnat print(f"{42:5e}") # value in e format print(f"{42:5E}") # value in E format print(f"{13.14564567:.5g}") # 5 sig figure print(f"{11113.14564567:.5g}") # 5 sig figure print(f"{1113.14564567:.5g}") # 5 sig figure print(f"{111113.14564567:.5g}") # 5 sig figure print(f"{111113.14564567:.5G}") # 5 sig figure print(f"{0.14122143:.5%}") # 5 sig figure #temp 5 print(True, False, type(True)) print(False == 0) x = True and 2 and [1] and {0} and -1.0 and "hello" # truthy value print(x) y = False or 0 or [] or {} or None or 0.00 or ' ' # falsy value print(y) print("aaa") print(print(" ")) print("bbb") #========================================== default_city = 'kw' city = '' city = city or print("please input city") or default_city print(city) #temp 6 name = ["john", "ann", "mary", "peter", ["ryan", 1], 2, 3, [True, 0,0,9, "hello"]] print(name, id(name), type(name)) print(name[0], name[4]) print(name[4][0]) name[0] = ["david", 20] name[4][0]= 'goodman' print(name) del name[1] print(name)
Editor Settings
Theme
Key bindings
Full width
Lines