A煤n no tienes acceso a esta clase

Crea una cuenta y contin煤a viendo este curso

Dictionary comprehensions

9/21
Recursos

Aportes 1103

Preguntas 26

Ordenar por:

驴Quieres ver m谩s aportes, preguntas y respuestas de la comunidad? Crea una cuenta o inicia sesi贸n.

Saludos! 鈥 mi aporte

def run():

    my_dict = {i : round(i**0.5,2) for i in  range(1,1001)}

    print(my_dict)

if __name__=='__main__':
    run()

La raiz cuadrada se puede calcular importando la librer铆a math.

Espero mi aporte sea de ayuda. Facil rapido y sencillo
.
.
#Desafio consiste hacer un diccionario comprehesion, donde las llaves sean los 1000 primeros numeros naturales con sus raices cuadradas como valor

dictionary = {i: i**0.5 for i in range(1, 1001) }
print(dictionary)

NOTA: Como conocimiento general, las raices se pueden tratar tambien como potencias. Les dejo un link para quien quiera saber mas al respecto
.
.
Raiz = Exponente Fracci贸n

Un peque帽o resumen, espero sirva !!

mi aporte, uso el 0.5 para no usar librerias extras para obtener la raiz cuadrada

Si no ponemos los dos puntos ( : ) al momento de hacer el dictionary comprehension si no solamente el valor, obtenemos un set comprehension que es una lo mismo solo que para los datos de tipo set.

>>> no_es_diccionario = {i**2 for i in range(1, 101)}

>>> type(no_es_diccionario)
> <class 'set'> 

馃惐鈥嶐煉 Solucionando el problema propuesto con Dictionary comprehensions.

def run():
    dictionary = {i: i**3 for i in range(1, 101)}
    print(dictionary)


if __name__ == "__main__":
    run()

Reto de dictionary comprehensions:

    from math import sqrt 
    # classic way
    my_dict = {i: i**0.5 for i in range (1, 1001)}
    print(my_dict)

    print("----------------->>>>>><<<<<<<------------------")
    # math module way
    my_dict2 = {i: sqrt(i) for i in range (1, 1001)}
    print(my_dict2)

Para que sea legible he decidido usar el m茅todo de round(). El primer par谩metro es el de la operaci贸n o el del n煤mero real mientras que el segundo par谩metro es la cantidad de n煤meros despu茅s de la coma como se puede ver en la primera figura. En la segunda figura aparecen los n煤meros con las dos decimas

my aporte

def run():

    my_dict = {i: round(i**.5, 2) for i in range(1, 1001) if i % 3 != 0}

    print(my_dict)

if __name__ == "__main__":
    run()
 my_dict = { i: math.sqrt(i) for i in range(1,1001) }

agregando numeros que no sean divisibles entre 3.

def run():

    my_dict = {}

    for i in range(1, 101):
        if i % 3 == 0:
            continue
        else:
            my_dict[i]= i**3

    print(my_dict)

if __name__ == '__main__':
    run()

Yo lo hice de esta manera para que no salieran numeros tan largos:

import math


def run():
    dictionary = {i: round(math.sqrt(i), 2) for i in range(1, 1001)}
    print(dictionary)


if __name__ == "__main__":
    run()
#Antes importar math con solo escribiendo al inicio:
#import math
super_dict = {number : round(math.sqrt(number), 2) for number in range (1,1001)}
        
print (super_dict)
def dict_compre():
    dict_cubo = {num: num**3 for num in range(1, 101) if num % 3  != 0}

    print(dict_cubo)


def challenge_root():
    raiz = 1/2
    dict_root = {num: num**raiz for num in range(1, 1001)}

    print(dict_root)


if __name__ == "__main__":
    dict_compre()
    challenge_root()

Hola comparto mi soluci贸n

my_dict = {x:x**(1/2) for x in range(1,1001)}
print(my_dict)

import math

def run():
    
    my_dict = {i: round(math.sqrt(i),2) for i in range (1, 1001)}

    print(my_dict)


if __name__ == '__main__':
    run()

Ac谩 ser铆a as铆 馃槃:

<code> 
dict = {i: round(i**0.5,5) for i in range(1,1001)}
  • Para cada i del 1 al 1000
  • se va a guardar i como llave, y la ra铆z cuadrada de i como elemento

mi aporte

import math


def run():
		my_dict = {i: round(math.sqrt(i),2) for i in range(1,1001)}

		print(my_dict)


if __name__ == "__main__":
    run()


Hola mi aporte

def run():
    pass

my_dict = {i: i**0.5 for i in range(1, 1001)}

print(my_dict)


if __name__ == "__main__":
    run()
from math import sqrt

    challenge = {i : round(sqrt(i),2) for i in range(1,1001)}

    # print(challenge)


    for key, value in challenge.items():
        print(f'La ra铆z cuadrada de {key} es {value}')

En consola 鈫

La raiz cuadrada de 1 es 1.0
La raiz cuadrada de 2 es 1.41
La raiz cuadrada de 3 es 1.73
La raiz cuadrada de 4 es 2.0
La raiz cuadrada de 5 es 2.24
La raiz cuadrada de 6 es 2.45
La raiz cuadrada de 7 es 2.65
La raiz cuadrada de 8 es 2.83
La raiz cuadrada de 9 es 3.0
La raiz cuadrada de 10 es 3.16
La raiz cuadrada de 11 es 3.32
La raiz cuadrada de 12 es 3.46
La raiz cuadrada de 13 es 3.61
La raiz cuadrada de 14 es 3.74
La raiz cuadrada de 15 es 3.87
La raiz cuadrada de 16 es 4.0
La raiz cuadrada de 17 es 4.12
...

Ps: la ra铆z cuadrada de un n煤mero no es m谩s que un n煤mero elevado a 0,5.

Mi aporte馃榿

Los primeros 100 resultados:

Dictionaries by comprehension

my_dict = { i : round(  i**(1/2) ,   2 )    for  i  in  range(1,1001)  }

    print(  my_dict ) 

Usando el m茅todo nativo de python pow()

pow() es el equivalente a usar **. El primer par谩metro es la base y el segundo el exponente.
Sabiendo que la ra铆z cuadrada es posible saberla elevando el n煤mero a 0.5. con pow() es posible.

<my_dict = {i: pow(i,0.5) for i in range(1, 101)}
print (my_dict)> 

Mi soluci贸n al reto:

def run():
    my_dict = {i:round(i**0.5, 2) for i in range(1, 11)}

    print(my_dict)


if __name__ == '__main__':
    run()

Using import math!!!

import math as math

def run():
    numbers = {x: math.sqrt(x) for x in range(1, 101)}
    print(numbers)

if __name__ == '__main__':
    run() 

Primer reto antes de ver el video:

def run():

    dict = {i: i**3 for i in range(1, 101)}
    print(dict)    

if __name__ == '__main__':
    run()

Reto 2

def run():
   
    dict = {i: i**3 for i in range(1, 101) if i % 3 != 0}
    print(dict)    

if __name__ == '__main__':
    run()

Animo que vamos a terminar el Phyton Challenge鈥
Los tres desafios con comentados

import math

# Challenge 1 Dictionary with Keys: number from 1 to 100, 
# Values: the cube of that number
def challenge1():
    dict = {i: i**3 for i in range(1, 101)}
    print(dict) 

# Challenge 2 Same as challenge 1 with the condition that 
# the number is not a multiple of 3. 
def challenge2():
    dict = {i: i**3 for i in range(1, 101) if i % 3 != 0}
    print(dict)

# Challenge 3 Dictionary with Keys: first 1000 natural numbers, 
# Values: roof of that number 
def challenge3():
    dict = {i: math.sqrt(i) for i in range(1, 1001)}
    print(dict)

def run():
    # challenge1()
    # challenge2()
    challenge3()
    
if __name__ == '__main__':
    run()

Utilice round para que se imprimieran con solo 3 decimales.

import math

def run():
    super_dict = {i: round(math.sqrt(i), 3) for i in range (1, 1001)}
    print(super_dict)


if __name__ == '__main__':
    run()
import math

def run():
    square_root_for_first_1000_natural_numbers = {i: math.sqrt(i) for i in range(1, 1001)}
    
    print(square_root_for_first_1000_natural_numbers)

if __name__ == '__main__':
    run()

Para el reto de Dictionary Comprehensions us茅 la funci贸n pow(), que recibe como par谩metros la base y el exponente .

<   # #Reto - Dictionary Comprehensions.
    dict_sqr = {i: pow(i, 0.5) for i in range(1,1001)}
    print(dict_sqr)> 

Y que le pregunto a Google c贸mo sacar la ra铆z cuadrada en Python, y que me sale con varias funciones y librer铆as y al final me qued茅 con lo m谩s simple:

    my_dict = {i: i**0.5 for i in range(1, 1001)}

Elevar el n煤mero por 0.5. En mi vida se me hab铆a ocurrido. Cosas que aprende uno

Reto cumplido:

def run():
  import math

  square_roots = { i:math.sqrt(i) for i in range(1,1001)}
  print(square_roots)

if __name__ == '__main__':
  run()

Mi soluci贸n

import math


def run():

    myDict = {i: math.sqrt(i) for i in range(1, 100)}

    print(myDict)


if __name__ == '__main__':
    run()

a = {i:i**0.5 for i in range(1,1001)}

No hab铆a visto que se puede hacer con el 0.5 jajja solo recor茅 como me ensema帽aron en el colegio

  my_dic ={i: i**3 for i in range(1,101) if 1%3 != 0}
    print(my_dic)
    my_dic2 = {i : i**(1/2) for i in range(1,1000)}
    print(my_dic2)

Comparto mi soluci贸n

import math

def run():
    # my_dict = {}

    # for i in range(1, 101):
    #     if i % 3 !=0:
    #         my_dict[i] = i**2

    print('Diccionario 1: ')
    my_dict = {i: i**3 for i in range (1,101) if i % 3 != 0 }

    print(my_dict)

    print('Diccionario 2: ')

    my_dict2 = {i: math.sqrt(i) for i in range (1,1001)}
    print(my_dict2)

if __name__ == "__main__":
    run() 
    my_dict = {i: math.sqrt(i) for i in range(1, 1001)}
    print(my_dict)

import math

#diccionario de los 1000 primeros numeros como llaves
#y con sus valores respectivos como la raiz cuadrada respectivamente
def run():
    my_dict={i: math.sqrt(i) for i in range(1,1001)}
    print(my_dict)

if __name__=='__main__':
    run()
#diccionario con llave: 100 primeros numeros
#valor: los 100 primeros numeros elevados al cuadrado
def run():
    dict={}
    for i in range(1,101):
        N=i
        key=N
        valor=N**2
        dict={key:valor}
        print(dict)

if __name__=='__main__':
    run()

Aqu铆 esta mi aporte y soluci贸n al minireto:

def dict_com_creation(exp, limit):
    """
    A function that returns a dictionary with the number and 
    and the result of the exponent specified in the params.
    exp --> The exponent you want to receive as value
    limit --> The lenght of the dictionary.
    return dictionary: Number(key) and exponent(value)
    """
    return {i: i**exp for i in range(1,limit)}

Este corresponde a una funci贸n que retorna un diccionario con el numero como llave y la potenciaci贸n respectiva como valor.
馃槄 馃挭

<code> 

def dictionary_cubed(n):
    dictionary = {i: i**0.5 for i in range(1, n)}
    return dictionary 

def run ():
    n = int(input("Ingresa un numero natural: "))
    dictionary = dictionary_cubed(n+1)
    for key, value in dictionary.items():
        print(f'{key} - {value}')
if __name__ == "__main__":
    run()

squares = {i:[i**0.5] for i in range(1, 101) }

veamos=
squares = {鈥渘atural_nums鈥:[i**3] for i in range(1, 101) if i > 0 and i % 1 == 0}

jijij

{1: 1.0, 2: 1.4142135623730951, 3: 1.7320508075688772, 4: 2.0, 5: 2.23606797749979, 6: 2.449489742783178, 7: 2.6457513110645907, 8: 2.8284271247461903, 9: 3.0, 10: 3.1622776601683795, 11: 3.3166247903554, 12: 3.4641016151377544, 13: 3.605551275463989, 14: 3.7416573867739413, 15: 3.872983346207417, 16: 4.0, 17: 4.123105625617661, 18: 4.242640687119285, 19: 4.358898943540674, 20: 4.47213595499958, 21: 4.58257569495584, 22: 4.69041575982343, 23: 4.795831523312719, 24: 4.898979485566356, 25: 5.0, 26: 5.0990195135927845, 27: 5.196152422706632, 28: 5.291502622129181, 29: 5.385164807134504, 30: 5.477225575051661, 31: 5.5677643628300215, 32: 5.656854249492381, 33: 5.744562646538029, 34: 5.830951894845301, 35: 5.916079783099616, 36: 6.0, 37: 6.082762530298219, 38: 6.164414002968976, 39: 6.244997998398398, 40: 6.324555320336759, 41: 6.4031242374328485, 42: 6.48074069840786, 43: 6.557438524302, 44: 6.6332495807108, 45: 6.708203932499369, 46: 6.782329983125268, 47: 6.855654600401044, 48: 6.928203230275509, 49: 7.0, 50: 7.0710678118654755, 51: 7.14142842854285, 52: 7.211102550927978, 53: 7.280109889280518, 54: 7.3484692283495345, 55: 7.416198487095663, 56: 7.483314773547883, 57: 7.54983443527075, 58: 7.615773105863909, 59: 7.681145747868608, 60: 7.745966692414834, 61: 7.810249675906654, 62: 7.874007874011811, 63: 7.937253933193772, 64: 8.0, 65: 8.06225774829855, 66: 8.12403840463596, 67: 8.18535277187245, 68: 8.246211251235321, 69: 8.306623862918075, 70: 8.366600265340756, 71: 8.426149773176359, 72: 8.48528137423857, 73: 8.54400374531753, 74: 8.602325267042627, 75: 8.660254037844387, 76: 8.717797887081348, 77: 8.774964387392123, 78: 8.831760866327848, 79: 8.888194417315589, 80: 8.94427190999916, 81: 9.0, 82: 9.055385138137417, 83: 9.1104335791443, 84: 9.16515138991168, 85: 9.219544457292887, 86: 9.273618495495704, 87: 9.327379053088816, 88: 9.38083151964686, 89: 9.433981132056603, 90: 9.486832980505138, 91: 9.539392014169456, 92: 9.591663046625438, 93: 9.643650760992955, 94: 9.695359714832659, 95: 9.746794344808963, 96: 9.797958971132712, 97: 9.848857801796104, 98: 9.899494936611665, 99: 9.9498743710662, 100: 10.0, 101: 10.04987562112089, 102: 10.099504938362077, 103: 10.14889156509222, 104: 10.198039027185569, 105: 10.246950765959598, 106: 10.295630140987, 107: 10.344080432788601, 108: 10.392304845413264, 109: 10.44030650891055, 110: 10.488088481701515, 111: 10.535653752852738, 112: 10.583005244258363, 113: 10.63014581273465, 114: 10.677078252031311, 115: 10.723805294763608, 116: 10.770329614269007, 117: 10.816653826391969, 118: 10.862780491200215, 119: 10.908712114635714, 120: 10.954451150103322, 121: 11.0, 122: 11.045361017187261, 123: 11.090536506409418, 124: 11.135528725660043, 125: 11.180339887498949, 126: 11.224972160321824, 127: 11.269427669584644, 128: 11.313708498984761, 129: 11.357816691600547, 130: 11.40175425099138, 131: 11.445523142259598, 132: 11.489125293076057, 133: 11.532562594670797, 134: 11.575836902790225, 135: 11.61895003862225, 136: 11.661903789690601, 137: 11.704699910719626, 138: 11.74734012447073, 139: 11.789826122551595, 140: 11.832159566199232, 141: 11.874342087037917, 142: 11.916375287812984, 143: 11.958260743101398, 144: 12.0, 145: 12.041594578792296, 146: 12.083045973594572, 147: 12.12435565298214, 148: 12.165525060596439, 149: 12.206555615733702, 150: 12.24744871391589, 151: 12.288205727444508, 152: 12.328828005937952, 153: 12.36931687685298, 154: 12.409673645990857, 155: 12.449899597988733, 156: 12.489995996796797, 157: 12.529964086141668, 158: 12.569805089976535, 159: 12.609520212918492, 160: 12.649110640673518, 161: 12.68857754044952, 162: 12.727922061357855, 163: 12.767145334803704, 164: 12.806248474865697, 165: 12.84523257866513, 166: 12.884098726725126, 167: 12.922847983320086, 168: 12.96148139681572, 169: 13.0, 170: 13.038404810405298, 171: 13.076696830622021, 172: 13.114877048604, 173: 13.152946437965905, 174: 13.19090595827292, 175: 13.228756555322953, 176: 13.2664991614216, 177: 13.30413469565007, 178: 13.341664064126334, 179: 13.379088160259652, 180: 13.416407864998739, 181: 13.45362404707371, 182: 13.490737563232042, 183: 13.527749258468683, 184: 13.564659966250536, 185: 13.601470508735444, 186: 13.638181696985855, 187: 13.674794331177344, 188: 13.711309200802088, 189: 13.74772708486752, 190: 13.784048752090222, 191: 13.820274961085254, 192: 13.856406460551018, 193: 13.892443989449804, 194: 13.92838827718412, 195: 13.96424004376894, 196: 14.0, 197: 14.035668847618199, 198: 14.071247279470288, 199: 14.106735979665885, 200: 14.142135623730951, 201: 14.177446878757825, 202: 14.212670403551895, 203: 14.247806848775006, 204: 14.2828568570857, 205: 14.317821063276353, 206: 14.352700094407323, 207: 14.38749456993816, 208: 14.422205101855956, 209: 14.45683229480096, 210: 14.491376746189438, 211: 14.52583904633395, 212: 14.560219778561036, 213: 14.594519519326424, 214: 14.628738838327793, 215: 14.66287829861518, 216: 14.696938456699069, 217: 14.730919862656235, 218: 14.7648230602334, 219: 14.798648586948742, 220: 14.832396974191326, 221: 14.866068747318506, 222: 14.89966442575134, 223: 14.933184523068078, 224: 14.966629547095765, 225: 15.0, 226: 15.033296378372908, 227: 15.066519173319364, 228: 15.0996688705415, 229: 15.132745950421556, 230: 15.165750888103101, 231: 15.198684153570664, 232: 15.231546211727817, 233: 15.264337522473747, 234: 15.297058540778355, 235: 15.329709716755891, 236: 15.362291495737216, 237: 15.394804318340652, 238: 15.427248620541512, 239: 15.459624833740307, 240: 15.491933384829668, 241: 15.524174696260024, 242: 15.556349186104045, 243: 15.588457268119896, 244: 15.620499351813308, 245: 15.652475842498529, 246: 15.684387141358123, 247: 15.716233645501712, 248: 15.748015748023622, 249: 15.7797338380595, 250: 15.811388300841896, 251: 15.84297951775486, 252: 15.874507866387544, 253: 15.905973720586866, 254: 15.937377450509228, 255: 15.968719422671311, 256: 16.0, 257: 16.0312195418814, 258: 16.06237840420901, 259: 16.09347693943108, 260: 16.1245154965971, 261: 16.15549442140351, 262: 16.186414056238647, 263: 16.217274740226856, 264: 16.24807680927192, 265: 16.278820596099706, 266: 16.30950643030009, 267: 16.34013463836819, 268: 16.3707055437449, 269: 16.401219466856727, 270: 16.431676725154983, 271: 16.46207763315433, 272: 16.492422502470642, 273: 16.522711641858304, 274: 16.55294535724685, 275: 16.583123951777, 276: 16.61324772583615, 277: 16.64331697709324, 278: 16.673332000533065, 279: 16.703293088490067, 280: 16.73320053068151, 281: 16.76305461424021, 282: 16.792855623746664, 283: 16.822603841260722, 284: 16.852299546352718, 285: 16.881943016134134, 286: 16.911534525287763, 287: 16.941074346097416, 288: 16.97056274847714, 289: 17.0, 290: 17.029386365926403, 291: 17.05872210923198, 292: 17.08800749063506, 293: 17.11724276862369, 294: 17.146428199482248, 295: 17.175564037317667, 296: 17.204650534085253, 297: 17.233687939614086, 298: 17.26267650163207, 299: 17.291616465790582, 300: 17.320508075688775, 301: 17.349351572897472, 302: 17.378147196982766, 303: 17.406895185529212, 304: 17.435595774162696, 305: 17.46424919657298, 306: 17.4928556845359, 307: 17.52141546793523, 308: 17.549928774784245, 309: 17.578395831246947, 310: 17.60681686165901, 311: 17.635192088548397, 312: 17.663521732655695, 313: 17.69180601295413, 314: 17.72004514666935, 315: 17.74823934929885, 316: 17.776388834631177, 317: 17.804493814764857, 318: 17.832554500127006, 319: 17.86057109949175, 320: 17.88854381999832, 321: 17.916472867168917, 322: 17.944358444926362, 323: 17.97220075561143, 324: 18.0, 325: 18.027756377319946, 326: 18.05547008526779, 327: 18.083141320025124, 328: 18.110770276274835, 329: 18.138357147217054, 330: 18.16590212458495, 331: 18.193405398660254, 332: 18.2208671582886, 333: 18.24828759089466, 334: 18.275666882497067, 335: 18.303005217723125, 336: 18.33030277982336, 337: 18.35755975068582, 338: 18.384776310850235, 339: 18.411952639521967, 340: 18.439088914585774, 341: 18.466185312619388, 342: 18.49324200890693, 343: 18.520259177452136, 344: 18.547236990991408, 345: 18.57417562100671, 346: 18.601075237738275, 347: 18.627936010197157, 348: 18.65475810617763, 349: 18.681541692269406, 350: 18.708286933869708, 351: 18.734993995195193, 352: 18.76166303929372, 353: 18.788294228055936, 354: 18.81488772222678, 355: 18.841443681416774, 356: 18.867962264113206, 357: 18.894443627691185, 358: 18.920887928424502, 359: 18.947295321496416, 360: 18.973665961010276, 361: 19.0, 362: 19.026297590440446, 363: 19.05255888325765, 364: 19.078784028338912, 365: 19.1049731745428, 366: 19.131126469708992, 367: 19.157244060668017, 368: 19.183326093250876, 369: 19.209372712298546, 370: 19.235384061671343, 371: 19.261360284258224, 372: 19.28730152198591, 373: 19.313207915827967, 374: 19.339079605813716, 375: 19.364916731037084, 376: 19.390719429665317, 377: 19.4164878389476, 378: 19.44222209522358, 379: 19.467922333931785, 380: 19.493588689617926, 381: 19.519221295943137, 382: 19.544820285692065, 383: 19.570385790780925, 384: 19.595917942265423, 385: 19.621416870348583, 386: 19.6468827043885, 387: 19.672315572906, 388: 19.697715603592208, 389: 19.72308292331602, 390: 19.748417658131498, 391: 19.77371993328519, 392: 19.79898987322333, 393: 19.82422760159901, 394: 19.849433241279208, 395: 19.87460691435179, 396: 19.8997487421324, 397: 19.924858845171276, 398: 19.949937343260004, 399: 19.974984355438178, 400: 20.0, 401: 20.024984394500787, 402: 20.049937655763422, 403: 20.074859899884732, 404: 20.09975124224178, 405: 20.12461179749811, 406: 20.149441679609886, 407: 20.174241001832016, 408: 20.199009876724155, 409: 20.223748416156685, 410: 20.248456731316587, 411: 20.273134932713294, 412: 20.29778313018444, 413: 20.322401432901575, 414: 20.346989949375804, 415: 20.37154878746336, 416: 20.396078054371138, 417: 20.42057785666214, 418: 20.445048300260872, 419: 20.46948949045872, 420: 20.493901531919196, 421: 20.518284528683193, 422: 20.54263858417414, 423: 20.566963801203133, 424: 20.591260281974, 425: 20.615528128088304, 426: 20.639767440550294, 427: 20.663978319771825, 428: 20.688160865577203, 429: 20.71231517720798, 430: 20.73644135332772, 431: 20.760539492026695, 432: 20.784609690826528, 433: 20.808652046684813, 434: 20.83266665599966, 435: 20.85665361461421, 436: 20.8806130178211, 437: 20.904544960366874, 438: 20.92844953645635, 439: 20.952326839756964, 440: 20.97617696340303, 441: 21.0, 442: 21.02379604162864, 443: 21.047565179849187, 444: 21.071307505705477, 445: 21.095023109728988, 446: 21.118712081942874, 447: 21.142374511865974, 448: 21.166010488516726, 449: 21.18962010041709, 450: 21.213203435596427, 451: 21.236760581595302, 452: 21.2602916254693, 453: 21.283796653792763, 454: 21.307275752662516, 455: 21.330729007701542, 456: 21.354156504062622, 457: 21.37755832643195, 458: 21.400934559032695, 459: 21.42428528562855, 460: 21.447610589527216, 461: 21.470910553583888, 462: 21.494185260204677, 463: 21.517434791350013, 464: 21.540659228538015, 465: 21.563858652847824, 466: 21.587033144922902, 467: 21.61018278497431, 468: 21.633307652783937, 469: 21.656407827707714, 470: 21.6794833886788, 471: 21.702534414210707, 472: 21.72556098240043, 473: 21.748563170931547, 474: 21.77154105707724, 475: 21.79449471770337, 476: 21.817424229271428, 477: 21.840329667841555, 478: 21.863211109075447, 479: 21.88606862823929, 480: 21.908902300206645, 481: 21.93171219946131, 482: 21.95449840010015, 483: 21.97726097583591, 484: 22.0, 485: 22.02271554554524, 486: 22.045407685048602, 487: 22.06807649071391, 488: 22.090722034374522, 489: 22.11334438749598, 490: 22.135943621178654, 491: 22.15851980616034, 492: 22.181073012818835, 493: 22.20360331117452, 494: 22.22611077089287, 495: 22.24859546128699, 496: 22.271057451320086, 497: 22.293496809607955, 498: 22.315913604421397, 499: 22.338307903688676, 500: 22.360679774997898, 501: 22.38302928559939, 502: 22.40535650240808, 503: 22.427661492005804, 504: 22.44994432064365, 505: 22.47220505424423, 506: 22.494443758403985, 507: 22.516660498395403, 508: 22.538855339169288, 509: 22.561028345356956, 510: 22.58317958127243, 511: 22.60530911091463, 512: 22.627416997969522, 513: 22.64950330581225, 514: 22.67156809750927, 515: 22.693611435820433, 516: 22.715633383201094, 517: 22.737634001804146, 518: 22.759613353482084, 519: 22.781571499789035, 520: 22.80350850198276, 521: 22.825424421026653, 522: 22.847319317591726, 523: 22.869193252058544, 524: 22.891046284519195, 525: 22.9128784747792, 526: 22.93468988235943, 527: 22.956480566497994, 528: 22.978250586152114, 529: 23.0, 530: 23.021728866442675, 531: 23.043437243605826, 532: 23.065125189341593, 533: 23.08679276123039, 534: 23.108440016582687, 535: 23.130067012440755, 536: 23.15167380558045, 537: 23.173260452512935, 538: 23.194827009486403, 539: 23.2163735324878, 540: 23.2379000772445, 541: 23.259406699226016, 542: 23.280893453645632, 543: 23.302360395462088, 544: 23.323807579381203, 545: 23.345235059857504, 546: 23.366642891095847, 547: 23.388031127053, 548: 23.40939982143925, 549: 23.430749027719962, 550: 23.45207879911715, 551: 23.473389188611005, 552: 23.49468024894146, 553: 23.515952032609693, 554: 23.53720459187964, 555: 23.558437978779494, 556: 23.57965224510319, 557: 23.600847442411894, 558: 23.62202362203543, 559: 23.643180835073778, 560: 23.664319132398465, 561: 23.68543856465402, 562: 23.706539182259394, 563: 23.727621035409346, 564: 23.748684174075834, 565: 23.769728648009426, 566: 23.790754506740637, 567: 23.811761799581316, 568: 23.83275057562597, 569: 23.853720883753127, 570: 23.874672772626646, 571: 23.895606290697042, 572: 23.916521486202797, 573: 23.93741840717165, 574: 23.958297101421877, 575: 23.979157616563597, 576: 24.0, 577: 24.020824298928627, 578: 24.041630560342615, 579: 24.06241883103193, 580: 24.08318915758459, 581: 24.1039415863879, 582: 24.124676163629637, 583: 24.145392935299274, 584: 24.166091947189145, 585: 24.186773244895647, 586: 24.20743687382041, 587: 24.228082879171435, 588: 24.24871130596428, 589: 24.269322199023193, 590: 24.289915602982237, 591: 24.310491562286437, 592: 24.331050121192877, 593: 24.351591323771842, 594: 24.372115213907882, 595: 24.392621835300936, 596: 24.413111231467404, 597: 24.43358344574123, 598: 24.454038521274967, 599: 24.474476501040833, 600: 24.49489742783178, 601: 24.515301344262525, 602: 24.535688292770594, 603: 24.55605831561735, 604: 24.576411454889016, 605: 24.596747752497688, 606: 24.61706725018234, 607: 24.63736998950984, 608: 24.657656011875904, 609: 24.677925358506133, 610: 24.698178070456937, 611: 24.71841418861655, 612: 24.73863375370596, 613: 24.758836806279895, 614: 24.779023386727733, 615: 24.79919353527449, 616: 24.819347291981714, 617: 24.839484696748443, 618: 24.859605789312106, 619: 24.879710609249457, 620: 24.899799195977465, 621: 24.919871588754223, 622: 24.939927826679853, 623: 24.95996794869737, 624: 24.979991993593593, 625: 25.0, 626: 25.019992006393608, 627: 25.03996805109783, 628: 25.059928172283335, 629: 25.079872407968907, 630: 25.099800796022265, 631: 25.11971337416094, 632: 25.13961017995307, 633: 25.15949125081825, 634: 25.179356624028344, 635: 25.199206336708304, 636: 25.219040425836983, 637: 25.238858928247925, 638: 25.25866188063018, 639: 25.278449319529077, 640: 25.298221281347036, 641: 25.317977802344327, 642: 25.337718918639855, 643: 25.357444666211933, 644: 25.37715508089904, 645: 25.39685019840059, 646: 25.41653005427767, 647: 25.436194683953808, 648: 25.45584412271571, 649: 25.475478405713993, 650: 25.495097567963924, 651: 25.514701644346147, 652: 25.534290669607408, 653: 25.553864678361276, 654: 25.573423705088842, 655: 25.592967784139454, 656: 25.612496949731394, 657: 25.632011235952593, 658: 25.65151067676132, 659: 25.67099530598687, 660: 25.69046515733026, 661: 25.709920264364882, 662: 25.729360660537214, 663: 25.748786379167466, 664: 25.768197453450252, 665: 25.787593916455254, 666: 25.80697580112788, 667: 25.826343140289914, 668: 25.84569596664017, 669: 25.865034312755125, 670: 25.88435821108957, 671: 25.903667693977237, 672: 25.92296279363144, 673: 25.942243542145693, 674: 25.96150997149434, 675: 25.98076211353316, 676: 26.0, 677: 26.019223662515376, 678: 26.038433132583073, 679: 26.057628441590765, 680: 26.076809620810597, 681: 26.095976701399778, 682: 26.115129714401192, 683: 26.13426869074396, 684: 26.153393661244042, 685: 26.1725046566048, 686: 26.19160170741759, 687: 26.210684844162312, 688: 26.229754097208, 689: 26.248809496813376, 690: 26.267851073127396, 691: 26.28687885618983, 692: 26.30589287593181, 693: 26.324893162176366, 694: 26.343879744638983, 695: 26.362852652928137, 696: 26.38181191654584, 697: 26.40075756488817, 698: 26.419689627245813, 699: 26.43860813280457, 700: 26.457513110645905, 701: 26.476404589747453, 702: 26.49528259898354, 703: 26.514147167125703, 704: 26.5329983228432, 705: 26.551836094703507, 706: 26.570660511172846, 707: 26.589471600616662, 708: 26.60826939130014, 709: 26.627053911388696, 710: 26.645825188948457, 711: 26.664583251946766, 712: 26.68332812825267, 713: 26.70205984563738, 714: 26.720778431774775, 715: 26.739483914241877, 716: 26.758176320519304, 717: 26.77685567799177, 718: 26.795522013948524, 719: 26.814175355583846, 720: 26.832815729997478, 721: 26.851443164195103, 722: 26.870057685088806, 723: 26.888659319497503, 724: 26.90724809414742, 725: 26.92582403567252, 726: 26.94438717061496, 727: 26.962937525425527, 728: 26.981475126464083, 729: 27.0, 730: 27.018512172212592, 731: 27.03701166919155, 732: 27.055498516937366, 733: 27.073972741361768, 734: 27.09243436828813, 735: 27.110883423451916, 736: 27.129319932501073, 737: 27.147743920996454, 738: 27.16615541441225, 739: 27.184554438136374, 740: 27.202941017470888, 741: 27.2213151776324, 742: 27.23967694375247, 743: 27.258026340878022, 744: 27.27636339397171, 745: 27.294688127912362, 746: 27.313000567495326, 747: 27.331300737432898, 748: 27.349588662354687, 749: 27.367864366808018, 750: 27.386127875258307, 751: 27.40437921208944, 752: 27.422618401604176, 753: 27.440845468024488, 754: 27.459060435491963, 755: 27.477263328068172, 756: 27.49545416973504, 757: 27.51363298439521, 758: 27.53179979587241, 759: 27.54995462791182, 760: 27.568097504180443, 761: 27.586228448267445, 762: 27.60434748368452, 763: 27.622454633866266, 764: 27.640549922170507, 765: 27.65863337187866, 766: 27.676705006196094, 767: 27.694764848252458, 768: 27.712812921102035, 769: 27.730849247724095, 770: 27.748873851023216, 771: 27.76688675382964, 772: 27.784887978899608, 773: 27.80287754891569, 774: 27.820855486487112, 775: 27.83882181415011, 776: 27.85677655436824, 777: 27.874719729532707, 778: 27.892651361962706, 779: 27.910571473905726, 780: 27.92848008753788, 781: 27.94637722496424, 782: 27.964262908219126, 783: 27.982137159266443, 784: 28.0, 785: 28.0178514522438, 786: 28.035691537752374, 787: 28.053520278211074, 788: 28.071337695236398, 789: 28.089143810376278, 790: 28.106938645110393, 791: 28.124722220850465, 792: 28.142494558940577, 793: 28.160255680657446, 794: 28.178005607210743, 795: 28.19574435974337, 796: 28.21347195933177, 797: 28.231188426986208, 798: 28.24889378365107, 799: 28.26658805020514, 800: 28.284271247461902, 801: 28.30194339616981, 802: 28.319604517012593, 803: 28.337254630609507, 804: 28.35489375751565, 805: 28.372521918222215, 806: 28.39013913315678, 807: 28.407745422683583, 808: 28.42534080710379, 809: 28.442925306655784, 810: 28.460498941515414, 811: 28.478061731796284, 812: 28.495613697550013, 813: 28.513154858766505, 814: 28.53068523537421, 815: 28.548204847240395, 816: 28.5657137141714, 817: 28.583211855912904, 818: 28.600699292150182, 819: 28.61817604250837, 820: 28.635642126552707, 821: 28.653097563788805, 822: 28.6705423736629, 823: 28.687976575562104, 824: 28.705400188814647, 825: 28.722813232690143, 826: 28.74021572639983, 827: 28.75760768909681, 828: 28.77498913987632, 829: 28.792360097775937, 830: 28.809720581775867, 831: 28.827070610799147, 832: 28.844410203711913, 833: 28.861739379323623, 834: 28.879058156387302, 835: 28.89636655359978, 836: 28.91366458960192, 837: 28.930952282978865, 838: 28.948229652260256, 839: 28.965496715920477, 840: 28.982753492378876, 841: 29.0, 842: 29.017236257093817, 843: 29.03446228191595, 844: 29.0516780926679, 845: 29.068883707497267, 846: 29.086079144497972, 847: 29.103264421710495, 848: 29.120439557122072, 849: 29.13760456866693, 850: 29.154759474226502, 851: 29.171904291629644, 852: 29.189039038652847, 853: 29.206163733020468, 854: 29.223278392404914, 855: 29.24038303442689, 856: 29.257477676655586, 857: 29.274562336608895, 858: 29.29163703175362, 859: 29.30870177950569, 860: 29.32575659723036, 861: 29.34280150224242, 862: 29.359836511806396, 863: 29.376861643136763, 864: 29.393876913398138, 865: 29.410882339705484, 866: 29.427877939124322, 867: 29.444863728670914, 868: 29.46183972531247, 869: 29.478805945967352, 870: 29.49576240750525, 871: 29.512709126747414, 872: 29.5296461204668, 873: 29.546573405388315, 874: 29.563490998188964, 875: 29.58039891549808, 876: 29.597297173897484, 877: 29.614185789921695, 878: 29.631064780058107, 879: 29.647934160747187, 880: 29.664793948382652, 881: 29.68164415931166, 882: 29.698484809834994, 883: 29.715315916207253, 884: 29.732137494637012, 885: 29.748949561287034, 886: 29.765752132274432, 887: 29.782545223670862, 888: 29.79932885150268, 889: 29.816103031751148, 890: 29.832867780352597, 891: 29.8496231131986, 892: 29.866369046136157, 893: 29.88310559496787, 894: 29.899832775452108, 895: 29.916550603303182, 896: 29.93325909419153, 897: 29.949958263743873, 898: 29.966648127543394, 899: 29.9833287011299, 900: 30.0, 901: 30.01666203960727, 902: 30.033314835362415, 903: 30.04995840263344, 904: 30.066592756745816, 905: 30.083217912982647, 906: 30.099833886584822, 907: 30.116440692751194, 908: 30.133038346638727, 909: 30.14962686336267, 910: 30.166206257996713, 911: 30.18277654557314, 912: 30.199337741083, 913: 30.215889859476256, 914: 30.23243291566195, 915: 30.24896692450835, 916: 30.265491900843113, 917: 30.28200785945344, 918: 30.298514815086232, 919: 30.315012782448235, 920: 30.331501776206203, 921: 30.347981810987037, 922: 30.364452901377952, 923: 30.380915061926625, 924: 30.397368307141328, 925: 30.4138126514911, 926: 30.430248109405877, 927: 30.44667469527666, 928: 30.463092423455635, 929: 30.479501308256342, 930: 30.495901363953813, 931: 30.512292604784715, 932: 30.528675044947494, 933: 30.54504869860253, 934: 30.56141357987225, 935: 30.577769702841312, 936: 30.59411708155671, 937: 30.610455730027933, 938: 30.62678566222711, 939: 30.643106892089126, 940: 30.659419433511783, 941: 30.675723300355934, 942: 30.692018506445613, 943: 30.708305065568176, 944: 30.72458299147443, 945: 30.740852297878796, 946: 30.757112998459398, 947: 30.773365106858236, 948: 30.789608636681304, 949: 30.805843601498726, 950: 30.822070014844883, 951: 30.83828789021855, 952: 30.854497241083024, 953: 30.870698080866262, 954: 30.886890422961002, 955: 30.903074280724887, 956: 30.919249667480614, 957: 30.93541659651604, 958: 30.95157508108432, 959: 30.967725134404045, 960: 30.983866769659336, 961: 31.0, 962: 31.016124838541646, 963: 31.0322412983658, 964: 31.04834939252005, 965: 31.064449134018133, 966: 31.080540535840107, 967: 31.096623610932426, 968: 31.11269837220809, 969: 31.12876483254676, 970: 31.144823004794873, 971: 31.160872901765767, 972: 31.176914536239792, 973: 31.192947920964443, 974: 31.20897306865447, 975: 31.22498999199199, 976: 31.240998703626616, 977: 31.25699921617557, 978: 31.272991542223778, 979: 31.28897569432403, 980: 31.304951684997057, 981: 31.32091952673165, 982: 31.336879231984796, 983: 31.352830813181765, 984: 31.368774282716245, 985: 31.38470965295043, 986: 31.400636936215164, 987: 31.416556144810016, 988: 31.432467291003423, 989: 31.448370387032774, 990: 31.464265445104548, 991: 31.480152477394387, 992: 31.496031496047245, 993: 31.51190251317746, 994: 31.52776554086889, 995: 31.54362059117501, 996: 31.559467676119, 997: 31.575306807693888, 998: 31.591137997862628, 999: 31.606961258558215, 1000: 31.622776601683793}
dictionary_challenge = { item: round((item**(0.5)), 2) for item in range(1, 1001)}
print(dictionary_challenge)

Comparto mi aporte resumido

<  from math import sqtr  
    Root= {} 
    Root= {i:sqrt(i) for i in range(1,1001)}
    print(Root)> 

yo lo resolv铆 de la siguiente forma:

my_dict={i: round(sqrt(i),2) for i in range (1, 1001)}

my_dict ={ i : i**0.5 for i in range(1, 1000+1)}

print(my_dict)

def run():
my_dict={i: i**(1/2) for i in range(1,1001,1)}
print(my_dict)

if name==鈥main鈥:
run()

yo lo resolv铆 de est谩 forma, utilice la librer铆a math y la funci贸n round para practicar, pero este ejercicio se puede desarrollar elevando i a 0.5 y quedar铆a mucho m谩s entendible a mi parecer.

def run():
    # my_dict = {}

    # for i in range(1,101):
    #     if i % 3 != 0:
    #         my_dict[i] = i**3

    #A continuacion usaremos dicts comprehensions
    # my_dict = {i: i**3 for i in range(1,101) if i % 3 != 0}

    #ahora, un diccionario con los 1eros 1000 numeros y sus raices
    my_dict = {i: i**0.5 for i in range(1,1001)}

    print(my_dict)

if __name__ == '__main__':
    run()

Este ser铆a el reto

my_result = {i: i**0.5 for i in range(1,1001)}
print (my_result)

Resultado del reto:

def run():
    raiz = { x : x**(1/2) for x in range(1, 1_001)}
    print(raiz)

if __name__ == '__main__':
    run()

def run():
    # my_dict = {}

    # for i in range(1,101):
    #     if i % 3 != 0: # num que no son divisibles por 3
    #         my_dict[i] = i**3

    # my_dict = {i: i**3 for i in range(1,101) if i % 3 != 0}

    my_dict = {i: round(i**(0.5), 2) for i in range(1,1001)}

    print(my_dict)


if __name__ == '__main__':
    run()

Diccionarios comprimidos (Dictionary comprehensions)

def run():

#  El equivalente en potencia de una ra铆z cuadrada es el
#  n煤mero elevado a la 1/2 (osea 0.5)
mi_dicci = {x: round(x**.5, 4) for x in range(1, 1001)}
print(mi_dicci)

if name == 鈥main鈥:
run()

import math

def challenge():
    challenge_dict = {i: round(math.sqrt(i),2) for i in range(1000)}
    print(challenge_dict)

if __name__ == '__main__':
	challenge()

Reto 2.

def run():
        new_dict = {i: math.sqrt(i) for i in range(1, 11)}

    for keys in new_dict:
        print(keys, '-', new_dict[keys])
    # print(new_dict)


if __name__ == '__main__':
    run()

Reto1.

def run():
    my_dict = {
        i for i in range (1,10)
    }
    all_dict = {values:values**3 for values in my_dict}
    print(my_dict)
    print(all_dict)


if __name__ == '__main__':
    run()

Mi c贸digo 馃槂

import math

def run():
    one_thousand = {i: round(math.sqrt(i), 3) for i in range(1, 1001)}

    print(one_thousand)



if __name__ == '__main__':
    run()

Mi peque帽o aporte, saludos

import math
def run():
my_dict = {i:math.sqrt(i) for i in range(1,1001)}
print (my_dict)

if name == 鈥main鈥:
run()

mi aporte

from cProfile import run
from math import sqrt

def run():

result={i: sqrt(i) for i in range (1,1001)}
print(result)

if name == 鈥main鈥:
run()

Mi solucion

#!/usr/bin/env python3

def challenge():
    '''Crea, cun un dictionary comprehension, un 
    diccionario cuyas llaves sean los 1000 primero numeros
    naturales con sus raices cuadradas cono valores
    '''

    challenge = {i: sqrt(i) for i in range(1, 1001)}
    print(challenge)
def reto():
    my_dict_comprehensions = {i:math.sqrt(i) for i in range(1,1001) if i % 3 !=3}
    print(my_dict_comprehensions)

dict_comprehensions = {i:i**2 for i in range(1,1000)}

usando la funcion sqrt

from cmath import sqrt

def run():


    sqrts = {i : sqrt(i) for i in range(1,1001)}
    print(sqrts)


if __name__ == '__main__':
    run()

my_dict = {i : i**0.5 for i in range (1, 1001)}

def run():
    import math
    ditc = {element: round(math.sqrt(element),2) for element in range(1,1000+1)}
    print(ditc)
if __name__=='__main__':
    run()

import math


def run():

    cuadrados = {i: math.sqrt(i) for i in range(1, 1001)}
    print(cuadrados)


if __name__ == "__main__":
    run()

Un vez vi una compa帽era que hizo un dict_comprenhension muy bonito! Saludos !

import numpy as np    
    
def run():
    reto = {i: round(np.sqrt(i),2) for i in range(1,101)}
    print(reto)

if __name__ == '__main__':
    run()

Resultado
{1: 1.0, 2: 1.41, 3: 1.73, 4: 2.0, 5: 2.24, 6: 2.45, 7: 2.65, 8: 2.83, 9: 3.0, 10: 3.16, 11: 3.32, 12: 3.46, 13: 3.61, 14: 3.74, 15: 3.87, 16: 4.0, 17: 4.12, 18: 4.24, 19: 4.36, 20: 4.47, 21: 4.58, 22: 4.69, 23: 4.8, 24: 4.9, 25: 5.0, 26: 5.1, 27: 5.2, 28: 5.29, 29: 5.39, 30: 5.48, 31: 5.57, 32: 5.66, 33: 5.74, 34: 5.83, 35: 5.92, 36: 6.0, 37: 6.08, 38: 6.16, 39: 6.24, 40: 6.32, 41: 6.4, 42: 6.48, 43: 6.56, 44: 6.63, 45: 6.71, 46: 6.78, 47: 6.86, 48: 6.93, 49: 7.0, 50: 7.07, 51: 7.14, 52: 7.21, 53: 7.28, 54: 7.35, 55: 7.42, 56: 7.48, 57: 7.55, 58: 7.62, 59: 7.68, 60: 7.75, 61: 7.81, 62: 7.87, 63: 7.94, 64: 8.0, 65: 8.06, 66: 8.12, 67: 8.19, 68: 8.25, 69: 8.31, 70: 8.37, 71: 8.43, 72: 8.49, 73: 8.54, 74: 8.6, 75: 8.66, 76: 8.72, 77: 8.77, 78: 8.83, 79: 8.89, 80: 8.94, 81: 9.0, 82: 9.06, 83: 9.11, 84: 9.17, 85: 9.22, 86: 9.27, 87: 9.33, 88: 9.38, 89: 9.43, 90: 9.49, 91: 9.54, 92: 9.59, 93: 9.64, 94: 9.7, 95: 9.75, 96: 9.8, 97: 9.85, 98: 9.9, 99: 9.95, 100: 10.0}

def run():
    my_diccionary={i:i**0.5 for i in range(1,1001) if 1==1}
    print(my_diccionary)

run() 

We can use import math.sqrt, pow(), and **0.5
c鈥檃 dejo la explicaci鈥檕n: https://www.delftstack.com/es/howto/python/square-root-in-python/
y este es mi intento!

#Challenge_Dicttionary_comprehensions
#get the value as the suare root of the key.
def run():

    print("\n This is another Dict_comprehension example!\n")
    mydict3 = {i : i**(0.5) for i in range(1,1001) } 
    print(mydict3)

if __name__ == "__main__":
    run()
import math

def run():
    # my_dict = {}
    # for i in range(1, 101):
    #     if i % 3 != 0:
    #         my_dict[i] = i**3

    my_dict = {i :math.sqrt(i) for i in range(1, 101) }

    print(my_dict)


if __name__ == '__main__':
    run()

RESULTADO:
{1: 1.0, 2: 1.4142135623730951, 3: 1.7320508075688772, 4: 2.0, 5: 2.23606797749979, 6: 2.449489742783178, 7: 2.6457513110645907, 8: 2.8284271247461903, 9: 3.0, 10: 3.1622776601683795, 11: 3.3166247903554, 12: 3.4641016151377544, 13: 3.605551275463989, 14: 3.7416573867739413, 15: 3.872983346207417, 16: 4.0, 17: 4.123105625617661, 18: 4.242640687119285, 19: 4.358898943540674, 20: 4.47213595499958, 21: 4.58257569495584, 22: 4.69041575982343, 23: 4.795831523312719, 24: 4.898979485566356, 25: 5.0, 26: 5.0990195135927845, 27: 5.196152422706632, 28: 5.291502622129181, 29: 5.385164807134504, 30: 5.477225575051661, 31: 5.5677643628300215, 32: 5.656854249492381, 33: 5.744562646538029, 34: 5.830951894845301, 35: 5.916079783099616, 36: 6.0, 37: 6.082762530298219, 38: 6.164414002968976, 39: 6.244997998398398, 40: 6.324555320336759, 41: 6.4031242374328485, 42: 6.48074069840786, 43: 6.557438524302, 44: 6.6332495807108, 45: 6.708203932499369, 46: 6.782329983125268, 47: 6.855654600401044, 48: 6.928203230275509, 49: 7.0, 50: 7.0710678118654755, 51: 7.14142842854285, 52: 7.211102550927978, 53: 7.280109889280518, 54: 7.3484692283495345, 55: 7.416198487095663, 56: 7.483314773547883, 57: 7.54983443527075, 58: 7.615773105863909, 59: 7.681145747868608, 60: 7.745966692414834, 61: 7.810249675906654, 62: 7.874007874011811, 63: 7.937253933193772, 64: 8.0, 65: 8.06225774829855, 66: 8.12403840463596, 67: 8.18535277187245, 68: 8.246211251235321, 69: 8.306623862918075, 70: 8.366600265340756, 71: 8.426149773176359, 72: 8.48528137423857, 73: 8.54400374531753, 74: 8.602325267042627, 75: 8.660254037844387, 76: 8.717797887081348, 77: 8.774964387392123, 78: 8.831760866327848, 79: 8.888194417315589, 80: 8.94427190999916, 81: 9.0, 82: 9.055385138137417, 83: 9.1104335791443, 84: 9.16515138991168, 85: 9.219544457292887, 86: 9.273618495495704, 87: 9.327379053088816, 88: 9.38083151964686, 89: 9.433981132056603, 90: 9.486832980505138, 91: 9.539392014169456, 92: 9.591663046625438, 93: 9.643650760992955, 94: 9.695359714832659, 95: 9.746794344808963, 96: 9.797958971132712, 97: 9.848857801796104, 98: 9.899494936611665, 99: 9.9498743710662, 100: 10.0}

Reto

Saludos, comparto el reto de la clase.

def run():
	   my_dict_test={key:round(key**(1/2),2) for key in range(1,1001)}
     print(my_dict_test)

if __name__=='__main__':
    run()

Este es mi aporte para la clase.

import math

def cube():
    cube = {i:math.sqrt(i) for i in range(1,1000)}

    print(cube)
if __name__ == '__main__':
    cube()
<def run():
    
    my_dict_raiz = {i: i**0.5 for i in range(1, 1001)}

    print (my_dict_raiz)


if __name__ == '__main__':
    run()> 
    import math
    my_dict = {i: round(math.sqrt(i),2) for i in range(1,1001)}
    print(my_dict)

dics_cubo = {num : num**3 for num in range(1, 101)}

print(dics_cubo)

dics_tres = {num : num**3 for num in range(1, 101) if num % 3 != 0}

print(dics_tres)

def run():
nums = [i for i in range(1, 99999) if i % 4 == 0 and i % 6 == 0 and i % 9 == 0]

print(nums)

if name == 鈥main鈥:
run()

<challenge_dictionary = {i: i**0.5 for i in range(1, 1001)}

print(challenge_dictionary)> 

#Se puede hacer con m贸dulos diferentes para el calculo de la ra铆z cuadrada. Comparto mi soluci贸n:

import math
import numpy as np

def run():
    my_dict = {i:math.sqrt(i) for i in range(1,1001)} #Tambien se puede hacer con np.sqrt por eso lo habia importado

    print(my_dict)

if __name__ == "__main__":
    run()

Aqu铆 esta mi aporte de Python lo logre usando el comando pow.

my_dict = {i: pow(i, 1/2) for i in range(1,1001)}
        
    print(my_dict)

Quedar铆a as铆, haciendo la importaci贸n de la librer铆a math que se hace con el comando import al inicio del programa as铆:

import math
 
my_dict = {i:math.sqrt(i) for i in range (1, 1001)}
print(my_dict)
def sqrt_natural_numbers():
    my_nat_num_list = {
        item: round(math.sqrt(item), 2) for item in range(1, 1001)
    }
    print(my_nat_num_list)
def dictionary_comprehention():
    my_dictionary = {
        item: item **3 for item in range(1, 101) if item % 3 != 0
    }
    print (my_dictionary)

Saludos

def run():
	my_dict = {f"element {i}": round(i**0.5,2) for i in range(1,1001)}
    print(my_dict) 

if __name__=="__main__":
    run()
import math

def main():

    dicc_natural = {i:math.sqrt(i) for i in range (1,1001)}
    print(dicc_natural)
if __name__ == "__main__":
    main()
import math
def main():

    reto = {i:math.sqrt(i)  for i in range(1, 1001)}
    print(reto)

if __name__ == "__main__":
    main()

Tambi茅n podemos llegar al valor indicado en el range si le sumamos uno al final
EJ:
for i in range(1, 100 + 1):

Esto nos va a imprimir hasta el 100,

 import math
    my_dict_raiz= {i:round(math.sqrt(i),2) for i in range (1,1001)}
import math 

def run():
    raices = {i:round(math.sqrt(i),3) for i in range (1, 1001)}
    print (raices)
if __name__== '__main__':
    run()

ejercicio list comprehensions

def run():
    list_comp =[i for i in range(1,100000) if (i % 4 == 0 and i % 6 == 0 and i % 9 == 0)]
    print(list_comp)



if __name__ == '__main__':
    run()

Reto Final

def main():
   
    my_dict = {i: i ** 0.5 for i in range(1, 1001)}
    print(my_dict)


if __name__ == '__main__':
    main()