Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- проверьте будет ли напечатано True or False
- 1. a_string = ’airplane’
- another_string = ’airplanes’
- print(len(another_string) >= len(a_string))
- 2. print(’100’ == 100)
- 3. print( (100 - 7) in [5, 1, 92, 7, 17, 13])
- 4. a_number = 2
- another_number = 17
- print( (a_number + another_number) > 19)
- 5. print(not False == True)
- 6. print(’a’.isupper() == (not False))
- 7. print(sorted([2, 4, 7, 1]) == [1, 2, 4, 7])
- 8. a_string = ’airplane’
- another_string = ’airplanes’
- print(a_string[0] != another_string[5])
- 9. a_string = ’airplane’
- another_string = ’airplanes’
- print(a_string[3:] == another_string[3:8])
- 10. a_list = [’hello’, [’what’, ’is’], ’happening’, ’here’]
- appended = a_list.append(’?’)
- print(appended == ’?’)
- 11. a_dict = {’a’: [1, 2], ’b’: ’hello’}
- print(len(a_dict[’a’]) <= 2)
- 12. a_set = set([1, 4, 6, 8, 2, 3, 1, 1, 3, 5])
- a_set.update([1, 3, 4, 1, 1])
- print(len(a_set) == 7)
- 13. letters = [’a’,’b’,’c’,’d’]
- numbers = set([1, 2, 3, 4, 5])
- print(all([len(letters) == 4,
- len(numbers) != 5]))
- 14. a_string = ’airplane’
- another_string = ’airplanes’
- print(any([len(a_string) == 7,
- a_string == another_string,
- (2 + 17 + 2) > 21]))
- 15. print(all([’airplane’.startswith(’air’),
- ’airplane’.replace(’a’, ’b’) == ’birplbne’,
- ’airplane’ not in [’the airplane’, ’is in the air’]
- ]))
- ответьте на воросы ниже.
- 16. что выведет len([5, 2, [1, 2], 3])?
- 17. объясните три способа Python’s slicing. К примеру что будет напечатано? "Bananas are yummy."[1:-1:2]
- 18. в чем разница между (args) (kwargs)?
- 19. объясните continue, break и pass statements do.
- 20. как простым способом рапечатать следующее построчно имя в отдельной строчке?
- print(" ".join(["Alan", "Maria", "Paul"]))
- 21. сократите выражение: a < b and c > b
- 22. какие два типа объектов задаются с помощью {}?
- 23. что такое max()? например: max([1,2,3])
- 24. как превратить строковой литерал в число (например ’1’) в integer?
- 25. как отсортировать список в обратном порядке с помощью sorted()?
- 26. какие встроенные функции нужо использовать для итерации по целым числам до 100?
- 27. какие встроенные функции нужо использовать чтобы получить справку о данной функции?
- как использовать *args и **kwargs in Python
- найти ошибку
- 1 shopping_list = {"apples": 5, "bananas": 3, "pineapples": 2}
- 2 for product in shopping_list:
- 3 number = shopping_list[product]
- 4 print("We need " + number + " " + product)
- 1 fruit = ["apple", "banana", "strawberry", "pineapple"]
- 2 fruit.add("mango")
- 1 fruit = ["apple", "banana", "strawberry", "pineapple"]
- 2 fruit_string = ",".join(fruit)
- 3 fruit = fruit_string.split()
- 4 print(fruit[1])
- 1 fruit1 = fruit2 = ["apple", "banana", "strawberry", "pineapple"]
- 2 fruit2.remove("apple")
- 3 print(fruit1[3])
- 1 def count_items_in_list(a_list):
- 2 count = 0
- 3 for item in a_list:
- 4 count += 1
- 5 return count
- 6
- 7 fruit = ["apple", "banana", "strawberry", "pineapple"]
- 8 count_items_in_list(fruit)
- 9 print(count)
- 1 number = 5
- 2 if number < 10:
- 3 print(number, "is lower than 10")
- 1 numbers = {1: "one", 2: "two", 3: "three"}
- 2 print(numbers["1"])
- 1 number = 5413
- 2 if 1 in number:
- 3 print("1 in", number)
- что значит вызвать модуль в качестве сценария
- что значит вызвать модуль с параметрами python mymod.py 50?
- Когда интерпретатор Python запускается с флагом -O?
- когда байт-код не будет записан в файл .pyc или .pyo?
- какова функция модуля __init__.py в пакете?
- что означет from пакет import *
- файл __init__.py в пакете содержит _all__ = ["echo", "surround", "reverse"] что это?
- Что делают if __name__ == “__main__”?
- что вернет hash(1.0) == hash(1)?
- что вернет[] == []? А [] is []?
- будут ли одинаковы id(a) id(b) при >>> a, b = 257, 257
- будут ли одинаковы id(a) id(b) при >>> a = 257 >>> b = 257
- будут ли одинаковы id(a) id(b) при >>> a = 255 >>> b = 255
- что вернет >>> 1 > (0 < 1) что вернет >>> 1 == (0 < 1)
- что вернет True + 1
- type([1]) type([1].append(2))
- a = float('inf')
- сколько булевых значений в [False, 1.0, "some_string", 3, True, [], False] а сколько типа int
- что будет напечатано
- t = ('one', 'two')
- for i in t:
- print(i)
- t = ('one')
- for i in t:
- print(i)
- t = ()
- print(t)
- в следующем коде
- class Myclass
- pass
- a=Myclass()
- будут ли равны
- MyClass.__hash__(a)==a.__hash__()==hash(a)
- Что вернет list(map(str.upper, ['a','d'] )) а map(str.upper, ['a','d'] ) ?
- какую роль исполняет __slots__
- что такое @classmethod
- что такое @staticmethod
- Рассмотрим следующий код
- class TestClass(object):
- @classmethod
- def f1(cls):
- print (cls.__name__)
- class TestClass2(TestClass):
- pass
- что будет напечатано
- TestClass.f1()
- TestClass2.f1()
- a = TestClass2()
- a.f1()
- Рассмотрим следующий код
- class My:
- num = 0
- def __init__(self):
- My.num = My.num + 1
- @staticmethod
- def showNum():
- print(My.num)
- a=My()
- b=My()
- что напечатает My.showNum()?
- My().showNum()
- а b.showNum()?
- как устроены абстрактные классы в Python?
- как организаована сериализация и десериализация в Python?
- назовите неизменяемые типы в Python?
- назовите изменяемые типы в Python?
- как задать неизменяемые типы в Python?
- Что делает следуюший код MyType = type('MyType', (object,), {'a': 1})?
- Какие типы можно исполльзовать в качестве ключей в словарях?
- Что означает переопределнный метод hash ?
- что произойдет при выполнении кода
- d=dict([("a",1),("a",21)])
- d
- чем отличаются встроенные методы str и repr?
- С уважением,
- Youri Pomelnikov
- toph@mail.ru
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement