Только начал свое знакомство с Python. Вроде бы код верный, но высвечивается ошибка. В чем может быть проблема?
Книга стоит a гривен и b копеек. Определите, сколько гривен и копеек нужно заплатить за n книг.
P.S. Задача очень простая, я понимаю, но мне я хочу разобраться в проблема, и как ее можно исправить
- Вопрос задан 19 окт. 2022
- 231 просмотр
- Вконтакте

Во-первых, это неверно. map() принимает два аргумента: функцию, которую нужно применить, и коллекцию, к которой её применяем. Ты, к тому же, скобку не закрыл.
a,b,n=map(float(input().split())
Надо так:
a,b,n=map(float, input().split() )
Во-вторых, по-моему, у тебя кривой расчёт. ИМХО, проще всего рассчитать цену книги в копейках, а потом уже отталкиваться от этого.
Jailed code python что означает
CodeJail manages execution of untrusted code in secure sandboxes. It is designed primarily for Python execution, but can be used for other languages as well.
Security is enforced with AppArmor. If your operating system doesn’t support AppArmor, then CodeJail won’t protect the execution.
CodeJail is designed to be configurable, and will auto-configure itself for Python execution if you install it properly. The configuration is designed to be flexible: it can run in safe mode or unsafe mode. This helps support large development groups where only some of the developers are involved enough with secure execution to configure AppArmor on their development machines.
If CodeJail is not configured for safe execution, it will execution Python using the same API, but will not guard against malicious code. This allows the same code to be used on safe-configured or non-safe-configured developer’s machines.
A CodeJail sandbox consists of several pieces:
- Sandbox environment. For a Python setup, this would be Python and associated core packages. This is denoted throughout this document as <SANDENV>. This is read-only.
- Sandbox packages. These are additional packages needed for a given run. For example, this might be a grader written by an instructor to run over a student’s code, or data that a student’s code might need to access. This is denoted throughout this document as <SANDPACK>. This is read-only.
- Untrusted packages. This is typically the code submitted by the student to be tested on the server, as well as any data the code may need to modify. This is denoted throughout this document as <UNTRUSTED_PACK>. This is currently read-only, but may need to be read-write for some applications.
- OS packages. These are standard system libraries needed to run Python (e.g. things in /lib). This is denoted throughout this document as <OSPACK>. This is read-only, and is specified by Ubuntu’s AppArmor profile.
To run, CodeJail requires two user accounts. One account is the main account under which the code runs, which has access to create sandboxes. This will be referred to as <SANDBOX_CALLER>. The second account is the account under which the sandbox runs. This is typically the account ‘sandbox.’
These instructions detail how to configure your operating system so that CodeJail can execute Python code safely. You can run CodeJail without these steps, and you will have an unsafe CodeJail. This is fine for developers’ machines who are unconcerned with security, and simplifies the integration of CodeJail into your project.
To secure Python execution, you’ll be creating a new virtualenv. This means you’ll have two: the main virtualenv for your project, and the new one for sandboxed Python code.
Choose a place for the new virtualenv, call it <SANDENV>. It will be automatically detected and used if you put it right alongside your existing virtualenv, but with -sandbox appended. So if your existing virtualenv is in /home/chris/ve/myproj, make <SANDENV> be /home/chris/ve/myproj-sandbox.
The user running the LMS is <SANDBOX_CALLER>, for example, you on your dev machine, or www-data on a server.
Other details here that depend on your configuration:
Create the new virtualenv:
(Optional) If you have particular packages you want available to your sandboxed code, install them by activating the sandbox virtual env, and using pip to install them:
Add a sandbox user:
Let the web server run the sandboxed Python as sandbox. Create the file /etc/sudoers.d/01-sandbox:
Edit an AppArmor profile. This is a text file specifying the limits on the sandboxed Python executable. The file must be in /etc/apparmor.d and must be named based on the executable, with slashes replaced by dots. For example, if your sandboxed Python is at /home/chris/ve/myproj-sandbox/bin/python, then your AppArmor profile must be /etc/apparmor.d/home.chris.ve.myproj-sandbox.bin.python:
Parse the profiles:
Reactivate your project’s main virtualenv again.
If your CodeJail is properly configured to use safe_exec, try these commands at your Python terminal:
This should fail with an exception.
If you need to change the packages installed into your sandbox’s virtualenv, you’ll need to disable AppArmor, because your sandboxed Python doesn’t have the rights to modify the files in its site-packages directory.
Disable AppArmor for your sandbox:
Install or otherwise change the packages installed:
Re-enable AppArmor for your sandbox:
In order to target the sandboxed Python environment(s) you have created on your system, you must set the following environment variables for testing:
Run the tests with the Makefile:
If CodeJail is running unsafely, many of the tests will be automatically skipped, or will fail, depending on whether CodeJail thinks it should be in safe mode or not.
CodeJail is general-purpose enough that it can be used in a variety of projects to run untrusted code. It provides two layers:
- jail_code.py offers secure execution of subprocesses. It does this by running the program in a subprocess managed by AppArmor.
- safe_exec.py offers specialized handling of Python execution, using jail_code to provide the semantics of Python’s exec statement.
CodeJail runs programs under AppArmor. AppArmor is an OS-provided feature to limit the resources programs can access. To run Python code with limited access to resources, we make a new virtualenv, then name that Python executable in an AppArmor profile, and restrict resources in that profile. CodeJail will execute the provided Python program with that executable, and AppArmor will automatically limit the resources it can access. CodeJail also uses setrlimit to limit the amount of CPU time and/or memory available to the process.
Name already in use
codejail / codejail / jail_code.py /
- Go to file T
- Go to line L
- Go to definition R
- Copy path
- Copy permalink
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
В чем проблема в решении задачи?
друзья, изучая программирование столкнулся с проблемой. В ide код работает и с любыми значениями и выдает правильный результат. При отправке кода на платформу stepic код выдает такую ошибку:
Мой код, который работает в IDE, но на который ругается Stepic
Подскажите пожалуйста куда копать, заранее благодарю за помощь!
![]()
Ваш код при введённой строке, если она состоит всего из одного символа, вылетит на строке if a[b] != a[c]: потому что c изначально равно 1, а a[1] находится за границей строки из одного символа.
Ваш код ошибается на строке из одного символа (падает из-за обращения за конец строки). Ещё не хватает перевода строки в конце, но это не существенно.
Если чинить ваш вариант, то нужно обработать строку из одного элемента, удалить дублирующиеся счётчики, убрать дублированную печать. Получится что-то такое:
В Питоне для алгоритмов работающих с группами одинаковых элементов есть itertools.groupby:
![]()
Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.3.11.43304
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.