37 pass
38 # '________________________'
39
40 familia_periodo = ("Elemento pertence a familia {}{} de periodo {}".format(int(coluna+1),familia,int(linha+1)))41
42 print(familia_periodo)
43
60 if escolha == "N":
61 continue #pular para outro tipo
62 if escolha == "Y":
63 Nome_Arquivo = ("{}.py".format(tipo)) 64
65 try:
66
53tipos = ("MASSA","ATOMICO","ESTADO","RADIO") #em caps para nome do arquvio e sem caps para nome do dicionario
54#massa
55for tipo in tipos:
56 print("tipo: {}".format(tipo)) 57
58 escolha = input("esse e o tipo para editar ? Y/N " )
59
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"