---
# System prepended metadata

title: Логіка

---

# Логіка

## Задачі

### Задача 1

```python=
if True:
    print("Тест 1")
    
if False:
    print("Тест 2")
```

### Задача 1.5

```python=
if False:
    print("Тест 1")
    
if True:
    print("Тест 2")

if True:
    print("Тест 3")
```

### Задача 2

```python=
if False:
    print("Тест 1")
    if True:
        print("Тест 2")
```

### Задача 3

```python=
test = True

if test:
    print("Тест 1")
    if test:
        print("Тест 2")

if False:
    print("Тест 3")
```

### Задача 4

```python=
test = True

if test:
    print("Тест 1")
else:
    print("Тест 2")
    
if True:
    print("Тест 3")
```

### Задача 5

```python=
if True:
    if True:
        print("test 1")
if True:
    if False:
        print("test 2")
if False:
    if True:
        print("test 3")
if False:
    if False:
        print("test 4")
```

### Задача 6

```python=
test1 = True

if test1:
    print("test 1")
if not test1:
    print("test 2")
```

### Задача 7

```python=
test2 = False

if test2:
    print("test 1")
if not not test2:
    print("test 2")
```

### Задача 8

```python=
test3 = "MY" in "this is my program"

if test3:
    print("test 1")
if not test3:
    print("test 2")
```

### Задача 9

```python=
test4 = "my" in "this is my program"
test5 = 10 > 0

if test4 and test5:
    print("test 1")
    
if test4 and not test5:
    print("test 2")
    
if not test4 and test5:
    print("test 3")
    
if not (test4 and test5):
    print("test 4")
    
if test4 or test5:
    print("test 5")
    
if not test4 or test5:
    print("test 6")
    
if not (test4 or test5):
    print("test 7")
```

### Задача 10

```python=
test1 = "hello" == "hello"
test2 = 1000 == 1000
test3 = 5000 == 1000
test4 = 10.0 == 10.1

test5 = "hello" != "hello"
test6 = " " != "  "
test7 = 10 < 9
test8 = 5.0 > 5
test9  = 999 >= 999
test10 = 999 <= 999
test11 = 999 != 999

test12 = 999 == 999
test13 = 999 == "999"
test14 = "999" != 999

test15 = "James Bond".startswith("James")
test16 = "James Bond".startswith("james")
test17 = "James Bond".endswith("bond")
test18 = "James Bond".islower()
test19 = "JAMES BOND".isupper()
test20 = "James" in "James Bond"
test21 = "JAMES" not in "James Bond"
test22 = James in "James Bond"

test23 = test15 and test16 or test7
test24 = 5 < 100 or test9 or test19
test25 = 5 > 100 or test9 or test19
test26 = "21" in "2021" and test11 and test12
```

### Задача 11

Переписати коротше

```python=
if a:
    if not b:
        print("test 1")
if not a:
    if not b:
        print("test 2")
```

### Задача 12

Переписати коротше

```python=
if a:
    if b:
        print("test 1")
        return
if a:
    if not b:
        print("test 2")
```
