sum(len(x) for x in cars.values())
from statistics import mean
for manufacturer, cars_data in cars.items():
print(manufacturer, "в среднем стоит", mean(cars_data.values()))
getcontact python
In [2]: s.pack("IBBIHH", 1, 2, 3, 4, 5, 6)
Out[2]: b'\x01\x00\x00\x00\x02\x03\x00\x00\x04\x00\x00\x00\x05\x00\x06\x00'
In [3]: len(s.pack("IBBIHH", 1, 2, 3, 4, 5, 6))
Out[3]: 16
In [8]: s.pack(">IBBIHH", 1, 2, 3, 4, 5, 6)
Out[8]: b'\x00\x00\x00\x01\x02\x03\x00\x00\x00\x04\x00\x05\x00\x06'
In [9]: len(s.pack(">IBBIHH", 1, 2, 3, 4, 5, 6))
Out[9]: 14
Note By default, the result of packing a given C struct includes pad bytes in order to maintain proper alignment for the C types involved; similarly, alignment is taken into account when unpacking. This behavior is chosen so that the bytes of a packed struct correspond exactly to the layout in memory of the corresponding C struct. To handle platform-independent data formats or omit implicit pad bytes, use standard size and alignment instead of native size and alignment: see Byte Order, Size, and Alignment for details.
def simple_command():
print("Привет")
def difficult_command():
print("Привет")
print("Введи число")
s = int(input()) ** 2
print("Вот его квадрат:", s)
cmd_to_fn = {
"1": simple_command,
"2": difficult_command,
"3": lambda: print("Совсем простая команда"),
}
cmd = input("Введи команду (1/2/3):")
while cmd not in cmd_to_fn:
cmd = input("Ты слепой? Тут есть только 1, 2 и 3. Давай ещё раз:")
print("Есть такая буква в этом слове. Вот её результат:")
cmd_to_fn[cmd]()