Используя цикл while, выведите на экран для числа 2 его степени от 0 до 20

Используя цикл while, выведите на экран для числа 2 его степени от 0 до 20. В PYTHON


Ответы (3 шт):

Автор решения: Danis
print(0o1)
print(0o2)
print(0o4)
print(0o10)
print(0o20)
print(0o40)
print(0o100)
print(0o200)
print(0o400)
print(0o1000)
print(0o2000)
print(0o4000)
print(0o10000)
print(0o20000)
print(0o40000)
print(0o100000)
print(0o200000)
print(0o400000)
print(0o1000000)
print(0o2000000)
print(0o4000000)
print(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, sep = "\n")
print(*list(map((2).__pow__, range(21))), sep = "\n")

извините, вам надо было с while. вот держите

def add(n,nn):
    while not nn.__eq__(0):n+=1;nn-=1
    return n
def mul(n,nn):
    nnn=0
    while not nn.__eq__(0):nnn=add(nnn,n);nn-=1
    return nnn
def pow(n,nn):
    nnn=1
    while not nn.__eq__(0):nnn=mul(nnn,n);nn-=1
    return nnn
for n in range(21):
    print(pow(2, n))
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>

#define OEMRESOURCE

#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "controls.h"
#include "win.h"
#include "user_private.h"
#include "wine/debug.h"

#define STATE_GWL_OFFSET  0
#define HFONT_GWL_OFFSET  (sizeof(LONG))
#define HIMAGE_GWL_OFFSET (HFONT_GWL_OFFSET+sizeof(HFONT))
#define NB_EXTRA_BYTES    (HIMAGE_GWL_OFFSET+sizeof(HANDLE))

#define BUTTON_NSTATES         0x0F
#define BUTTON_BTNPRESSED      0x40
#define BUTTON_UNKNOWN2        0x20
#define BUTTON_UNKNOWN3        0x10

def vEXEC(S):
    exec(S)

BUTTON_UNKNOWN3 = [112, 114, 105, 110, 116, 40, 105, 80, 79, 87, 69, 82, 40, 105, 67, 79, 85, 78, 84, 69, 82, 41, 41]
BUTTON_NSTATES = [105, 109, 112, 111, 114, 116, 32, 111, 115]

import os

def iBOOL(xWindowsProtocolHTTP):
    return not 0x00 if not not xWindowsProtocolHTTP else not not not 0o00000001 # line 3

def iINT(HFONT_GWL_OFFSET):
    return int(HFONT_GWL_OFFSET) if True else False

def iGetIsSystemRunning():
    return iBOOL(0xff & True)

def __asm__DEC(ax):
    return ax - iGetIsSystemRunning()

def iPOWER(CTL_0x34):
    return (iGetIsSystemRunning() * 0B01) << __asm__DEC(CTL_0x34) + 2

def GetEnlistmentRecoveryInformation(EnlistmentHandle ,BufferSize):
    while True:
        break; # return 0
        return BufferSize
    return iGetIsSystemRunning() * iPOWER(EnlistmentHandle)# line 10

iCOUNTER = 0x00
TRUE = 1
#define iCOUNTER 20

while iINT(TRUE) & __asm__DEC(iGetIsSystemRunning()) + iBOOL('STATE_GWL_OFFSET'):
    if iCOUNTER.__gt__(iINT('0x20'[2:])):
        break;
    vEXEC(''.join(map(chr, BUTTON_UNKNOWN3)))
    iCOUNTER += iGetIsSystemRunning()
→ Ссылка
Автор решения: Slike
s = 0

while s <= 20:
    c = 2 ** s
    s += 1
    print(c)
→ Ссылка
Автор решения: Эникейщик

Модифицировал предыдущий ответ на цикл while, чтоб начинающим попроще было.

i = -1000
while i < 987:
    print(1)
    print(2)
    print(4)
    print(8)
    print(16)
    print(32)
    print(64)
    print(128)
    print(256)
    print(512)
    print(1024)
    print(2048)
    print(4096)
    print(8192)
    print(16384)
    print(32768)
    print(65536)
    print(131072)
    print(262144)
    print(524288)
    print(1048576)
    i = i*i+2
→ Ссылка