study-python-fastapi/Hometask 2.py
2024-11-25 14:17:41 +00:00

77 lines
No EOL
1.4 KiB
Python

my_string = "Hello, World!"
my_integer = 42
my_float = 3.14
my_bool = True
my_list = [1, 2, 3, 4, 5]
my_dict = {"key1": "value1", "key2": "value2"}
my_tuple = (1, 2, 3)
my_none = None
num1 = 10
num2 = 20
print(num1 < num2)
str1 = "apple"
str2 = "banana"
print(str1 == str2)
bool1 = True
bool2 = False
print(bool1 and bool2)
list1 = [1, 2, 3]
list2 = [1, 2, 3]
print(list1 == list2)
dict1 = {"key1": "value1", "key2": "value2"}
dict2 = {"key1": "value1", "key2": "value2"}
print(dict1 == dict2)
tuple1 = (1, 2, 3)
tuple2 = (1, 2, 3)
print(tuple1 == tuple2)
num_str = 125
num_str = str(num_str)
message = "Hi, my name is Python!"
message = message.replace('y', '0').replace('i', '1')
split_test = "This is a split test"
split_list = split_test.split(' ')
string_join = ' '.join(split_list)
length_of_string_join = len(string_join)
print(num_str)
print(message)
print(string_join)
print(length_of_string_join)
list_append = [1, 2, 3]
list_append.append(4)
list_append.append(5)
list_extend = [4, 5, 6]
list_extend.extend([7, 8, 9])
index_of_6 = list_extend.index(6)
length_of_list_append = len(list_append)
print(list_append)
print(list_extend)
print(index_of_6)
print(length_of_list_append)
dict_test = {'car': 'Toyota', 'price': 4900, 'where': 'EU'}
print(dict_test['car'])
print(dict_test['where'])
keys = dict_test.keys()
values = dict_test.values()
print(keys)
print(values)
items = dict_test.items()
print(items)