Documente Academic
Documente Profesional
Documente Cultură
blog.carreralinux.com.ar
1 de 4 4/7/19 10:26 a. m.
Funciones de la librería estándar de Python: cómo... about:reader?url=https://blog.carreralinux.com.a...
2 de 4 4/7/19 10:26 a. m.
Funciones de la librería estándar de Python: cómo... about:reader?url=https://blog.carreralinux.com.a...
3 de 4 4/7/19 10:26 a. m.
Funciones de la librería estándar de Python: cómo... about:reader?url=https://blog.carreralinux.com.a...
import random
4 de 4 4/7/19 10:26 a. m.
Listas en Python: las estructuras de datos más uti... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
Listas en Python
1 de 4 4/7/19 10:26 a. m.
Listas en Python: las estructuras de datos más uti... about:reader?url=https://blog.carreralinux.com.a...
devolverá el valor 7.
2 de 4 4/7/19 10:26 a. m.
Listas en Python: las estructuras de datos más uti... about:reader?url=https://blog.carreralinux.com.a...
jugadores1=jugadores[1:4]
jugadores2=jugadores[3:7]
3 de 4 4/7/19 10:26 a. m.
Listas en Python: las estructuras de datos más uti... about:reader?url=https://blog.carreralinux.com.a...
4 de 4 4/7/19 10:26 a. m.
Formato de strings en Python - Blog Carrera Linux about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
Formato de strings
nombre = 'Sergio'
edad = 39
1 de 3 4/7/19 10:26 a. m.
Formato de strings en Python - Blog Carrera Linux about:reader?url=https://blog.carreralinux.com.a...
siguiente:
2 de 3 4/7/19 10:26 a. m.
Formato de strings en Python - Blog Carrera Linux about:reader?url=https://blog.carreralinux.com.a...
anteriores:
Espero que este post les haya resultado útil. Para aprender
más sobre el tema no se pierdan el próximo.
3 de 3 4/7/19 10:26 a. m.
Compilación de programas en Linux - Blog Carrer... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
Compilación de programas
1 de 3 4/7/19 10:27 a. m.
Compilación de programas en Linux - Blog Carrer... about:reader?url=https://blog.carreralinux.com.a...
main()
#include <stdio.h>
2 de 3 4/7/19 10:27 a. m.
Compilación de programas en Linux - Blog Carrer... about:reader?url=https://blog.carreralinux.com.a...
Paso a paso
3 de 3 4/7/19 10:27 a. m.
Manipular strings con Python: más ejemplos - Blo... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
1 de 3 4/7/19 10:27 a. m.
Manipular strings con Python: más ejemplos - Blo... about:reader?url=https://blog.carreralinux.com.a...
argumentos:
saludo.ljust(20, '*')
len(saludo.ljust(20, '*'))
saludo.rjust(20, '-')
len(saludo.rjust(20, '-'))
saludo.center(20, '-')
len(saludo.center(20, '-'))
2 de 3 4/7/19 10:27 a. m.
Manipular strings con Python: más ejemplos - Blo... about:reader?url=https://blog.carreralinux.com.a...
otroSaludo.strip()
'Feliz jueves'
otroSaludo.lstrip()
otroSaludo.rstrip()
'==========Feliz=jueves=='
3 de 3 4/7/19 10:27 a. m.
Uso de diccionarios en Python: ejemplo - Blog Ca... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
1 de 3 4/7/19 10:28 a. m.
Uso de diccionarios en Python: ejemplo - Blog Ca... about:reader?url=https://blog.carreralinux.com.a...
import pprint
primerCapitulo = '''
'''
conteo = {}
conteo.setdefault(palabra, 0)
conteo[palabra] = conteo[palabra] + 1
pprint.pprint(conteo)
2 de 3 4/7/19 10:28 a. m.
Uso de diccionarios en Python: ejemplo - Blog Ca... about:reader?url=https://blog.carreralinux.com.a...
3 de 3 4/7/19 10:28 a. m.
Llaves en diccionarios: get y setdefault - Blog Car... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
Llaves en diccionarios
1 de 3 4/7/19 10:29 a. m.
Llaves en diccionarios: get y setdefault - Blog Car... about:reader?url=https://blog.carreralinux.com.a...
2 de 3 4/7/19 10:29 a. m.
Llaves en diccionarios: get y setdefault - Blog Car... about:reader?url=https://blog.carreralinux.com.a...
Espero que este post les haya resultado útil. ¡Nos leemos en
breve!
3 de 3 4/7/19 10:29 a. m.
Diccionarios en Python: otra estructura de datos -... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
1 de 3 4/7/19 10:29 a. m.
Diccionarios en Python: otra estructura de datos -... about:reader?url=https://blog.carreralinux.com.a...
2 de 3 4/7/19 10:29 a. m.
Diccionarios en Python: otra estructura de datos -... about:reader?url=https://blog.carreralinux.com.a...
3 de 3 4/7/19 10:29 a. m.
Expresiones regulares en Python: uso de tuberías ... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
1 de 3 4/7/19 10:30 a. m.
Expresiones regulares en Python: uso de tuberías ... about:reader?url=https://blog.carreralinux.com.a...
import re
superHeroes = re.compile(r'(Bat|Super|Aqua|Spider)man')
mo.group()
mo.group(1)
Resumen
2 de 3 4/7/19 10:30 a. m.
Expresiones regulares en Python: uso de tuberías ... about:reader?url=https://blog.carreralinux.com.a...
if mo:
mo.group()
mo.group(1)
3 de 3 4/7/19 10:30 a. m.
Módulo re en Python: expresiones regulares - Blo... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
El módulo re en Python
1 de 5 4/7/19 10:31 a. m.
Módulo re en Python: expresiones regulares - Blo... about:reader?url=https://blog.carreralinux.com.a...
Las funciones
2 de 5 4/7/19 10:31 a. m.
Módulo re en Python: expresiones regulares - Blo... about:reader?url=https://blog.carreralinux.com.a...
import re
3 de 5 4/7/19 10:31 a. m.
Módulo re en Python: expresiones regulares - Blo... about:reader?url=https://blog.carreralinux.com.a...
Ejemplo final
4 de 5 4/7/19 10:31 a. m.
Módulo re en Python: expresiones regulares - Blo... about:reader?url=https://blog.carreralinux.com.a...
5 de 5 4/7/19 10:31 a. m.
Conteo y orden con Python: diccionarios al rescate... about:reader?url=https://blog.carreralinux.com.a...
blog.carreralinux.com.ar
import pprint
import collections
primerCapitulo = '''
1 de 4 4/7/19 10:31 a. m.
Conteo y orden con Python: diccionarios al rescate... about:reader?url=https://blog.carreralinux.com.a...
'''
conteo = {}
conteo.setdefault(palabra, 0)
conteo[palabra] = conteo[palabra] + 1
conteoEnOrden = collections.Counter(conteo)
pprint.pprint(conteoEnOrden.most_common())
2 de 4 4/7/19 10:31 a. m.
Conteo y orden con Python: diccionarios al rescate... about:reader?url=https://blog.carreralinux.com.a...
3 de 4 4/7/19 10:31 a. m.
Conteo y orden con Python: diccionarios al rescate... about:reader?url=https://blog.carreralinux.com.a...
Espero que este post les haya resultado útil. ¡Nos leemos en
breve!
4 de 4 4/7/19 10:31 a. m.
python - Crear un diccionario anidado de un dicc... about:reader?url=https://code.i-harness.com/es/q...
code.i-harness.com
output = {}
for k, v in source.items():
current = output
pieces = k.split('_')
current[piece] = {}
1 de 4 4/7/19 10:35 a. m.
python - Crear un diccionario anidado de un dicc... about:reader?url=https://code.i-harness.com/es/q...
current = current[piece]
current[pieces[-1]] = v
2 de 4 4/7/19 10:35 a. m.
python - Crear un diccionario anidado de un dicc... about:reader?url=https://code.i-harness.com/es/q...
a la salida
usando el código
def nest_once(inp_dict):
out = {}
if isinstance(inp_dict, dict):
for key, val in inp_dict.items():
if '_' in key:
head, tail = key.split('_', 1)
3 de 4 4/7/19 10:35 a. m.
python - Crear un diccionario anidado de un dicc... about:reader?url=https://code.i-harness.com/es/q...
out[head].update({tail:
val})
else:
out[key] = val
return out
test_out = nest_once(test_dict)
(En cuanto a por qué quiero hacer esto: tengo un archivo cuya
estructura es equivalente a un dict anidado, y quiero
almacenar el contenido de este archivo en el diccionario de
atributos de un archivo NetCDF y recuperarlo más tarde. Sin
embargo, NetCDF solo te permite pongo diccionarios planos
como los atributos, así que quiero unflatten el diccionario que
guardé previamente en el archivo NetCDF.)
4 de 4 4/7/19 10:35 a. m.
Programando con Python / Python Core: Diccionarios http://pycartagena.pbworks.com/w/page/3668468...
Programando con Python Get a free wiki | Try our free business product log in help
If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.
VIEW EDIT
Los diccionarios son algo completamente distinto. No son del todo secuencias,sino mas bien se conocen Navigator
Operaciones: ch03
ch04
Miembros:
operador k in D comprueba si el objeto k es una de las claves del diccionario D retornando true o false. Contenido-Temático
Ejercicios
Pages Files options
Indexando:
>>> D = {'food': 'Spam', 'quantity': 4, 'color': 'pink'}
SideBar
Podemos indexar ese diccionario por clave para buscar y cambiar el valor de la llave asociada.
Notese que el item dentro del corchete es una clave, no su posición relativa como ocurre en la lista. Excepciones
Septima Sesión
Sábado 2 de Abril de 2011
Arrojar el valor clave de 'food':
>>> D['food']
'Spam'
Recent Activity
Sumarle 1 al valor de "quantity"
FrontPage
>>> D['quantity'] += 1 edited by juanpedro
>>> D
{'food': 'Spam', 'color': 'pink', 'quantity': 5} FrontPage
edited by juanpedro
Anidamiento:
1 de 4 4/7/19 12:41 p. m.
Programando con Python / Python Core: Diccionarios http://pycartagena.pbworks.com/w/page/3668468...
Supongamos algo mas complejo donde necesitemos guardar el nombre y apellido, junto con los
diferentes trabajos a través del anidado ( nesting).
>>> rec
{'nombre': {'1ero': 'Wilderman', 'apel': 'Ceren'}, 'job': ['desarrollador',
'management'], 'age': 34.6}
>>> rec['job'][-1]
'management'
>>> rec['job'].append('webmaster')
>>> rec
{'nombre': {'1ero': 'Wilderman', 'apel': 'Ceren'}, 'job': ['desarrollador',
'management', 'webmaster'], 'age': 34.6}
Métodos no-mutantes:
Siendo D un objeto diccionario:
D.copy( )
D.has_key(k)
D.items( )
D.keys( )
D.values( )
D.iteritems( )
D.iterkeys( )
D.itervalues( )
D.get(k[, x])
Métodos mutantes:
D.clear( )
D.update(D1)
D.setdefault(k[, x])
D.pop(k[, x])
D.popitem( )
2 de 4 4/7/19 12:41 p. m.
Programando con Python / Python Core: Diccionarios http://pycartagena.pbworks.com/w/page/3668468...
>>> Ks = list(D.keys())
>>> Ks
['a', 'c', 'b']
>>> D
{'a': 1, 'c': 3, 'b': 2}
Iteración y Optimización:
Protocolo de Iteración: Secuencia fisicamente almacenada en la memoria. Aplica para las expresiones de
comprensión de lista:
3 de 4 4/7/19 12:41 p. m.
Programando con Python / Python Core: Diccionarios http://pycartagena.pbworks.com/w/page/3668468...
>>> squares = []
>>> for x in [1, 2, 3, 4, 5]:
... squares.append(x ** 2)
...
>>> squares
[1, 4, 9, 16, 25]
Importante: La comprensión de lista similar a las funciones map y filter, correrá más rapido que un ciclo
for hoy dia.
>>> D
{'a': 1, 'c': 3, 'b': 2}
>>> D['e'] = 99
>>> D
{'a': 1, 'c': 3, 'b': 2, 'e': 99}
>>> D['f']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'f'
Verificación con método get (indice condicional con un valor x por defecto):
>>> value = D.get('f',0)
>>> value
0
Comments (0)
Printable version
4 de 4 4/7/19 12:41 p. m.
Python – Iterar sobre diccionario anidado about:reader?url=https://codeday.me/es/qa/2019...
codeday.me
{
'key_1': 'value_1',
'key_2': {'key_21': [(2100, 2101), (2110,
2111)],
'key_22': ['l1', 'l2'],
'key_23': {'key_231': 'v'},
'key_24': {'key_241': 502,
'key_242': [(5, 0), (7, 0)],
'key_243': {'key_2431': [0, 0],
'key_2432': 504,
1 de 2 4/7/19 12:42 p. m.
Python – Iterar sobre diccionario anidado about:reader?url=https://codeday.me/es/qa/2019...
'key_24412':'v_24412'
},
'key_2441': ['ll1', 'll2']
}
},
}
}
2 de 2 4/7/19 12:42 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
analyticslane.com
1 de 6 5/7/19 6:11 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
1. %time task()
2.
3. # CPU times: user 15.7 ms, sys: 4.83 ms, total: 20.5 ms
5.
6. %timeit task()
7.
2 de 6 5/7/19 6:11 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
1. %%time
2. task()
3. task()
4.
5. # CPU times: user 20.7 ms, sys: 1.19 ms, total: 21.9 ms
7.
8. %%timeit
9. task()
10. task()
11.
12. # 20.5 ms ± 243 µs per loop (mean ± std. dev. of 7 runs, 100
loops each)
3 de 6 5/7/19 6:11 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
Listado de variables
1. a = 1
2. b = 2
4 de 6 5/7/19 6:11 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
3. c = a + b
4.
5. %who_ls
['NamespaceMagics',
'a',
'autopep8',
'b',
'c',
'get_ipython',
'getsizeof',
'json',
'np',
'var_dic_list']
Conclusiones
5 de 6 5/7/19 6:11 p. m.
Seis comandos mágicos de Jupyter Notebooks - A... about:reader?url=https://www.analyticslane.com...
Sin votos
Contenido relacionado
6 de 6 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
analyticslane.com
Introducción
1 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
1. %matplotlib inline
2. import numpy as np
2.
6. plt.hist(data,
2 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
8. color=color)
9. plt.show()
3 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
2. interact(plot_function)
3. None
4 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
1. interact(plot_function,
7. None
5 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
Conclusiones
Imágenes: Pixabay
6 de 7 5/7/19 6:11 p. m.
Creación de gráficos interactivos en Jupyter Not... about:reader?url=https://www.analyticslane.com...
Sin votos
Contenido relacionado
7 de 7 5/7/19 6:11 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
ligdigonzalez.com
1 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
2 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Pandas
Numpy
3 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
SciPy
4 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Matplotlib
5 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Seaborn
Bokeh
6 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Scikit-learn
7 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Theano
8 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Keras
9 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
TensorFlow
10 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
Scrapy
11 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
NLTK
12 de 13 6/7/19 12:14 p. m.
Librerías de Machine Learning con Python - Ligdi... about:reader?url=http://ligdigonzalez.com/libreri...
13 de 13 6/7/19 12:14 p. m.
Python Desktop News Notifier in 20 lines - Geeks... about:reader?url=https://www.geeksforgeeks.org...
geeksforgeeks.org
Feedparser wil parse the feed that we will get from the URL. We
will use notify2 for the desktop notification purpose. Other than
these two libararies, we will use OS and time lib. Once you are
done with the installation import both libraries in the program.
Here, in this example i have parsed the news from the BBC UK,
you can use any news feedparser URL. Let’s have a look at the
program:
import feedparser
import notify2
import os
import time
1 de 4 7/7/19 9:03 a. m.
Python Desktop News Notifier in 20 lines - Geeks... about:reader?url=https://www.geeksforgeeks.org...
def parseFeed():
notify2.init('News Notify')
n =
notify2.Notification(newsitem['title'],
newsitem['summary'],
icon=ICON_PATH
)
n.set_urgency(notify2.URGENCY_NORMAL)
n.show()
n.set_timeout(15000)
time.sleep(1200)
if _name_ = '_main_':
parseFeed()
2 de 4 7/7/19 9:03 a. m.
Python Desktop News Notifier in 20 lines - Geeks... about:reader?url=https://www.geeksforgeeks.org...
1. f = feedparser.parse("http://feeds.bbci.co.uk
/news/rss.xml")
Here feedparser will parse the news data from the feed URL. The
parsed data will be in the form of dictionary.
If you want to set any icon in the notification then here we are
setting the Icon path. This is optional.
3. notify2.init('News Notify')
Here we are initializing the notify2 using the init method of notify2.
Initialize the D-Bus connection. Must be called before you send
any notifications, or retrieve server info or capabilities.
newsitem['summary'],
icon=ICON_PATH
)
Looping from the parsed data to get the relevant information like
news title, short summary and setting the notification icon using the
Notification method of the notify2 lib.
5. n.set_urgency(notify2.URGENCY_NORMAL)
3 de 4 7/7/19 9:03 a. m.
Python Desktop News Notifier in 20 lines - Geeks... about:reader?url=https://www.geeksforgeeks.org...
6. n.show()
7. n.set_timeout(15000)
8. time.sleep(1200)
This will usually display the news notification every 20 mins. You
can set the time as per your requirement. You can find the full
source code that is hosted on GitHub
4 de 4 7/7/19 9:03 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
instructables.com
1 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Here below video, you may see what you are going to get as
output ...
That is you might have run the program on the command line
and got the output in the same. But to make your code
interacting with the user you need an Interface to
communicate.
There are many modules in the python which you can import
and code your GUI. Tkinter is the built-in GUI for the python, It
comes installed with your python software. Also, you may also
try PyQT, Kivy(best for cross-platform ie same code in python
can be used to create apk, exe or MAC software)
https://kivy.org/#home
2 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
top.mainloop()
Explanations:
3 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Note:
Here I am going to use only one button and 4-row entry for
easy understanding.
top = Tkinter.Tk()
L1 = Label(top, text="My
calculator",).grid(row=0,column=1)
L2 = Label(top, text="Number
1",).grid(row=1,column=0)
L3 = Label(top, text="Number
2",).grid(row=2,column=0)
4 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
L4 = Label(top,
text="Operator",).grid(row=3,column=0)
L4 = Label(top,
text="Answer",).grid(row=4,column=0)
E1 = Entry(top, bd =5)
E1.grid(row=1,column=1)
E2 = Entry(top, bd =5)
E2.grid(row=2,column=1)
E3 = Entry(top, bd =5)
E3.grid(row=3,column=1)
E4 = Entry(top, bd =5)
E4.grid(row=4,column=1)
B=Button(top, text
="Submit",).grid(row=5,column=1,)
top.mainloop()
def proces():
5 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
number1=Entry.get(E1)
number2=Entry.get(E2)
operator=Entry.get(E3)
and get here means get the value the user has entered. Also, I
stored in the 3 variables namely as number1, number2,
operator
Step 3: Process
number1= int(number1)
number2=int(number2)
6 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
number1=int(number1)
number2=int(number2)
if operator =="+":
answer=number1+number2
if operator =="-":
answer=number1-number2
if operator=="*":
answer=number1*number2
if operator=="/":
answer=number1/number2
Entry.insert(E4,0,answer)
7 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
number1=int(number1)
number2=int(number2)
if operator =="+":
answer=number1+number2
if operator =="-":
answer=number1-number2
if operator=="*":
answer=number1*number2
if operator=="/":
answer=number1/number2
Entry.insert(E4,0,answer)
print(answer)
top = Tkinter.Tk()
L1 = Label(top, text="My
calculator",).grid(row=0,column=1)
L2 = Label(top, text="Number
1",).grid(row=1,column=0)
L3 = Label(top, text="Number
2",).grid(row=2,column=0)
L4 = Label(top,
text="Operator",).grid(row=3,column=0)
L4 = Label(top,
text="Answer",).grid(row=4,column=0)
E1 = Entry(top, bd =5)
E1.grid(row=1,column=1)
E2 = Entry(top, bd =5)
E2.grid(row=2,column=1)
8 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
E3 = Entry(top, bd =5)
E3.grid(row=3,column=1)
E4 = Entry(top, bd =5)
E4.grid(row=4,column=1)
B=Button(top, text ="Submit",command =
proces).grid(row=5,column=1,)
top.mainloop()
9 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Type the value of the in letters the console says Value error
thus for it we can do the warning
def proces():
try:
number1=Entry.get(E1)
number2=Entry.get(E2)
operator=Entry.get(E3)
number1=int(number1)
number2=int(number2)
if operator =="+":
answer=number1+number2
if operator =="-":
answer=number1-number2
if operator=="*":
answer=number1*number2
if operator=="/":
answer=number1/number2
Entry.insert(E4,0,answer)
print(answer)
except ValueError:
tkMessageBox.showwarning("Warning","Please
enter the value in integer")
10 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Considering the fact that you have created your python code,
and completely working after debugging errors... but there is a
final problem, If you want to share your python code to others,
they must be having the python installed this is not possible.
Also If you wish not to disclose your code creating EXE is the
best way.
There are many such options to freeze your code one I would
suggest is by using Pyinstaller.
step1:
Step 2:
11 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Thus you can also add your ico for your exe and bundle it up
within one file with the second command.
Step 6: Conclusion
Short Explanation:
12 de 13 7/7/19 9:07 a. m.
How to Make Your First Simple Software Using P... about:reader?url=https://www.instructables.com/...
Short Explanation:
With love
(N.Aranganathan)
Share
Recommendations
13 de 13 7/7/19 9:07 a. m.
Count of lines required to write the given String -... about:reader?url=https://www.geeksforgeeks.org...
geeksforgeeks.org
The task is to find the number of lines it’ll take to write the
string str on a paper and the width of the last line upto which it
is occupied.
Note: Width of a line is 10 units.
1 de 2 7/7/19 9:09 a. m.
Count of lines required to write the given String -... about:reader?url=https://www.geeksforgeeks.org...
1, 1, 1, 1, 1}
Output: (3, 6)
All the characters have the same width of 1. To write all 26
characters,
We need 2 full lines and one line with width 6 units.
2 de 2 7/7/19 9:09 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
opensource.com
Functions
1 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
#!/usr/bin/env python3
import time
def Timer():
$ touch mymodularity/__init__.py
2 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
To use your function, treat it just like any other Python module.
Here's a small application that tests the accuracy of Python's
sleep() function, using your mymodularity package for
support. Save this file as sleeptest.py outside the
mymodularity directory (if you put this into mymodularity,
then it becomes a module in your package, and you don't want
that).
#!/usr/bin/env python3
import time
# modularity
timestamp.Timer()
time.sleep(3)
timestamp.Timer()
3 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
$ python3 ./sleeptest.py
Time is 1560711266.1526039
Time is 1560711269.1557732
4 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
#!/usr/bin/env python3
import time
# no modularity
time.sleep(3)
For a simple example like this, there's not really a reason you
wouldn't write your sleep test that way, but the best part about
writing your own module is that your code is generic so you
5 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
#!/usr/bin/env python3
import time
# updated code
def Timer(msg):
print(str(msg) + str(time.time() ) )
6 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
#!/usr/bin/env python3
input()
print("Count to 3...")
input()
7 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
$ python3 ./response.py
Count to 3...
$ python3 ./sleeptest.py
8 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
timestamp.Timer()
#!/usr/bin/env python3
9 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
input()
print("Count to 3...")
input()
print(msg)
$ python3 ./response.py
10 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
Count to 3...
print(msg)
Return statements
11 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
#!/usr/bin/env python3
import time
def Timer(msg):
print(str(msg) + str(time.time() ) )
charge = .02
return charge
The timestamp module now charges two cents for each call,
but most importantly, it returns the amount charged each time
it is called.
#!/usr/bin/env python3
12 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
total = 0
while True:
kbd = input()
if kbd.lower() == "q":
exit()
else:
13 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
total = total+charge
$ python3 ./charge.py
Time is 1560722430.345412
Time is 1560722430.933996
Time is 1560722434.6027434
Time is 1560722438.612629
14 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
Time is 1560722439.3649364
Inline functions
#!/usr/bin/env python3
import time
total = 0
def Timer(msg):
15 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
print(str(msg) + str(time.time() ) )
charge = .02
return charge
while True:
kbd = input()
if kbd.lower() == "q":
exit()
else:
16 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
total = total+charge
Global variables
17 de 18 7/7/19 9:14 a. m.
Get modular with Python functions about:reader?url=https://opensource.com/article/...
Wrapping up functions
18 de 18 7/7/19 9:14 a. m.
Finding Mean, Median, Mode in Python without l... about:reader?url=https://www.geeksforgeeks.org/...
geeksforgeeks.org
perm_identityUser Actions
n = len(n_num)
get_sum = sum(n_num)
mean = get_sum / n
Output:
1 de 5 7/7/19 9:15 a. m.
Finding Mean, Median, Mode in Python without l... about:reader?url=https://www.geeksforgeeks.org/...
n = len(n_num)
n_num.sort()
if n % 2 == 0:
median1 = n_num[n//2]
median2 = n_num[n//2 - 1]
else:
median = n_num[n//2]
2 de 5 7/7/19 9:15 a. m.
Finding Mean, Median, Mode in Python without l... about:reader?url=https://www.geeksforgeeks.org/...
3. Mode : The mode is the number that occurs most often within
a set of numbers. This code calculates Mode of a list
containing numbers:
from collections import Counter
n_num = [1, 2, 3, 4, 5, 5]
n = len(n_num)
data = Counter(n_num)
get_mode = dict(data)
if len(mode) == n:
else:
print(get_mode)
3 de 5 7/7/19 9:15 a. m.
Finding Mean, Median, Mode in Python without l... about:reader?url=https://www.geeksforgeeks.org/...
then initialize a list with a For Loop to compare all the dict
values (Number of elements) to the max of all dict values
(count of most occurring element) and it returns all the
elements equal to max count. If the elements returned are
equal to the number of total elements in a list then we print out
‘No mode’, else we print out the modes returned.
Conclusion
We have successfully calculated mean, median and mode of a
dataset but you might be thinking ‘Will I be using these
algorithms every time I want to get mean, median and mode of
a dataset?’
The answer is you can but you certainly won’t. This was just to
show you how the algorithm works behind the scenes when
finding out any of these.
For any projects, this can be achieved by simply importing an
inbuilt library ‘statistics’ in Python 3 and using the inbuilt
functions mean(), median() and mode(). Also, there are other
external libraries which can help you achieve the same results
in just 1 line of code as the code is pre-written in those
libraries.
4 de 5 7/7/19 9:15 a. m.
Finding Mean, Median, Mode in Python without l... about:reader?url=https://www.geeksforgeeks.org/...
5 de 5 7/7/19 9:15 a. m.