CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 13:31:33 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=c7413c319f66bfd592f062db9f5b8f3e515c5238c44b0edd9533ac6a2bd64fd1a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%224QfIPenKn1yJKAmthZW9SXyHEdVgm6YI%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ceb7eccb2c9dfa-BLR
Chapter 3 - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # Задача №1
- # Напишите цикл for, который выводит ASCII-коды всех символов в строке
- # с именем S.
- S = "Foobarbaz"
- for char in S: print(ord(char), end=", ")
- # результат: 70, 111, 111, 98, 97, 114, 98, 97, 122
- # Затем измените цикл так, чтобы он вычислял сумму кодов ASCII всех
- # символов в строке.
- S = "Foobarbaz"
- sum = 0
- for char in S:
- char_code=(ord(char))
- sum += char_code
- print(sum)
- # результат: 918
- ################
- # Задача №2
- # Измените свой программный код так, чтобы он возвращал список,
- # содержащий ASCII-коды всех символов в строке.
- # вариант №1
- S = "Foobarbaz"
- char_code_list = []
- for char in S:
- char_code_list.append(ord(char))
- print(char_code_list)
- # результат: [70, 111, 111, 98, 97, 114, 98, 97, 122]
- # вариант №2
- S = "Foobarbaz"
- print([ord(char) for char in S])
- # результат: [70, 111, 111, 98, 97, 114, 98, 97, 122]
- # вариант №3
- S = "Foobarbaz"
- print(list(map(ord, S)))
- # результат: [70, 111, 111, 98, 97, 114, 98, 97, 122]
- # вариант №4
- S = "Foobarbaz"
- char_code_list = []
- for char in S:
- char_code_list += [(ord(char))]
- print(char_code_list)
- # результат: [70, 111, 111, 98, 97, 114, 98, 97, 122]
- #####################################################
- # Задача №3
- # Напишите цикл for, который выводит элементы словаря в порядке
- # возрастания.
- D = {'c': 2, 'b': 3, 'a': 1}
- for item in sorted(D.items()):
- print(item, end=", ")
- # результат: ('a', 1), ('b', 3), ('c', 2),
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐Exchange Exploit⭐⭐ 1
JavaScript | 2 sec ago | 0.24 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 2 sec ago | 0.10 KB
-
⭐ ✅ Free Products Method ✅ ✅ NEVER SEEN BEFOR...
JavaScript | 4 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ A
JavaScript | 13 sec ago | 0.24 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 13 sec ago | 0.10 KB
-
⭐ G2A Bug ⭐ (Get more on BTC swaps) ✅ NEVER S...
JavaScript | 14 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 23 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 6
JavaScript | 24 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand