Найти - Пользователи
Полная версия: Помогите разобраться
Начало » Python для новичков » Помогите разобраться
1 2
TIMP
p = int(input(“Показатель степени: ”))
n = int(input(“Максимальный предел степени: ”))
i = 1
while i**p <= n:
print(i**p, end=' ')
i += 1
print(“\nПоследнее число, возводимое в степень:”, i-1)
пишет ошибку в 5 строке. Что тут не так?
Romissevd
Текст ошибки нужно писать, ибо догадываться что у Вас за ошибка нет желания.
Код нужно оборачивать в теги.
doza_and
Romissevd
пишет ошибку в 5 строке. Что тут не так?
Скорее всего отступ
Romissevd
doza_and
Скорее всего отступ
Соглашусь с Вами полностью, так как код вполне рабочий…
A.N.Onim
а что за вывод такой:
print(i**p, end=' ')

что означает вывести
 end=' ' 

?
JOHN_16
A.N.Onim
Зачем это спрашивать, если это прекрасно гуглится

print(*objects, sep=' ‘, end=’\n', file=sys.stdout, flush=False)
Print objects to the text stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.

All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.

The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Since printed arguments are converted to text strings, print() cannot be used with binary mode file objects. For these, use file.write(…) instead.

Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.

Changed in version 3.3: Added the flush keyword argument.
sewer_in
A.N.Onim
а что за вывод такой:
A.N.Onim
а что за вывод такой:
Это значит, что в конце будет пробел, а не переход на новую строку.
A.N.Onim
А, тю, вообще не заметил что это третий питон)
lexa24
Могу ошибаться, поскольку не силен в программировании, но когда я одним принтом выводил несколько объектов, то питон просил, чтоб я писал через +. Вот так примерно:
print (i**p+'\t')
JOHN_16
lexa24
в питоне 2 версии функция (не оператор) print это лишь т.н. синтаксический сахар для print оператора. В питоне 3 версии функция print совершенно другая. Поэтому результат выполнения будет разный.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB