basicsPython/less-02/task-01.py
2022-02-21 22:24:16 +03:00

27 lines
1022 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Создать список и заполнить его элементами различных типов данных.
# Реализовать скрипт проверки типа данных каждого элемента. Использовать
# функцию type() для проверки типа. Элементы списка можно не запрашивать
# у пользователя, а указать явно, в программе
def print_type(el):
if (type(el) == list or type(el) == tuple):
print(el,' : ',type(el), end=' --> ')
for e in el:
print(e, end=' : ')
print(type(e), end=', ')
elif(type(el) == dict):
print(el, ' : ', type(el), end=' --> ')
for e in el.items():
print(e[0],' : ',e[1],end=', ')
else:
print(el, end=' : ')
print(type(el), end=', ')
my_list=[12, 3.14, 'python', False, [12,34,56], (1,2,3), {'a':1,'b':2}]
for el in my_list:
print_type(el)
print('')