Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Python Dictionary example

#!/usr/bin/python

dict = {}
dict['one'] = "This is one"
dict[2]     = "This is two"

tinydict = {'name': 'john','code':6734, 'dept': 'sales'}


print dict['one']       # Prints value for 'one' key
print dict[2]           # Prints value for 2 key
print tinydict          # Prints complete dictionary
print tinydict.keys()   # Prints all the keys
print tinydict.values() # Prints all the values
print dict          # Prints complete dictionary
print dict.keys()   # Prints all the keys
print dict.values() # Prints all the values

Papa Sport

# Hello World program in Python
import random

players = { "rank1": ["Yuri","Noam","Oren"],
        "rank2": ["Dani","Boaz","Omer"],
        "rank3": ["Yoni","Lior","Eyal"],
        "rank4": ["Jacob","Jonathan","Kobi"],
        "rank5": ["leonid","Idan","Adi"]
        }
all = []
for key in players:
    random.shuffle(players[key])
    all += players[key]
    
for i in range(0,3):
    print "Group {} is {}".format(i+1,all[i::3])

Execute Python Online

#il mio primo programma
a=2
b=0
for cnt in range(5):
    b=input()+b
    print("c: "+str(b)+"\n")

Execute Python Online

somma=0
for cnt in range (5):
    n=input()
    somma=somma+n
print "somma:"+str(somma)

somma numeri

# My first program
somma=0
for cnt in range(5):
    a=input()
    somma=somma+a
print "somma:"+str(somma)

1SommaNumeriCiclo

# My first program

a=0
for cnt in range(5):
    b=input()
    a=a+b
print a

Execute Python Online

# My first programm
Somma=0
for cnt in range(5):
    a=input()
    Somma=Somma+a
print "Somma: " + str (Somma)

SOMMA NUMERI

# MY FIRST PROGRAM
SOMMA = 0    
for CNT in range (5):
    N = input ()
    SOMMA = SOMMA + N
print "SOMMA:" + str (SOMMA)

Python Ex2

# Hello World program in Python
    
print "Hello Welcome to Python!\n"
cat_output1 = " ________________________"
cat_output2 = "< Pet me and I will purr. > "
cat_output3 = " ------------------------"
cat_direction = '/'
cat_img1 = "/ \ _ / \ "
cat_img2 = "( o . o )"
cat_img3 = ">   ^   <"

print cat_output1
print cat_output2
print cat_output3
print cat_direction
print cat_direction
print cat_img1
print cat_img2
print cat_img3

Trabajo

# Analisis Numerico
# Primer cuatrimestre 2018
# Trabajo Practico de Introduccion a Python
# Alumno: Matias N. Navarro
# Numero de Registro: 875.553

# Tarea realizada: El presente trabajo consiste en preparar un Sistema tal que permita calcular raices compleja de una cuadratica. A continuacion se realizara la misma paso a paso, junto con una breve descripcion de cada uno para una mejor comprension.

# El primer paso consiste en importar el paquete cmath, mediante el cual me va a permitir calcular raices complejas, puesto que dicha funcion no viene por defecto en Python:

import cmath 

# Una vez importado el paquete que contiene la funcion, se le solicitara al sistema que en su ejecucion exponga una breve descripcion del sistema:

print("Este sistema calcula raices complejas de una cuadratica")

# A continuacion, se definen los numeros a utilizar:

a=8
b=7
c=5

# Una vez definidos los numeros, solicitamos al sistema que calcule las raices complejas de la cuadratica, ya previamente mecionada:

discRoot = cmath.sqrt(complex(b * b - 4 * a * c))
root1 = (-b + discRoot) / (2 * a) #Raiz 1 como solucion del sistema
root2 = (-b - discRoot) / (2 * a) #Raiz 2 como solucion del sistema
" \n"
print("Las soluciones de este sistema son", root1, root2 )

Previous 1 ... 4 5 6 7 8 9 10 ... 866 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.