.dsy:it. Pages (4): [1] 2 3 4 »
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Programmazione avanzata (http://www.dsy.it/forum/forumdisplay.php?forumid=437)
-- esercizi (http://www.dsy.it/forum/showthread.php?threadid=40010)


Posted by eli88 on 14-02-2010 17:59:

esercizi

qualcuno potrebbe mettere gli esercizi che il prof ha fatto fare durante il corso? almeno così si possono confrontare.


Posted by zzz on 17-02-2010 14:24:

Sono interessato anch'io , qualcuno potrebbe postarli
Grazie


Posted by Didjer Wallis on 19-02-2010 09:45:

in rete si trovano parecchi esercizi di python2, nulla di python3 (magari cerco male io). se qualcuno sà darmi dei link ad esercizi di python3 o postare direttamente gli esercizi svolti farebbe un grossissimo piacere a tutti.

__________________
La vita è dolore!


Posted by Nvideo on 21-05-2010 12:43:

Ciao a tutti,
qualcuno ha risolto gli esercizi 2 e 3 dell'esercitazione 3?
Come avete fatto? :?

Grazie


Posted by Vikyg13 on 12-01-2011 12:02:

Riesumo il topic per sapere se da qualche parte si trovano le soluzioni degli esercizi di PA di quest'anno (2010-2011) o se almeno riusciamo ad aiutarci fra di noi


Posted by Vikyg13 on 02-02-2011 18:38:

nessuno insomma sta preparando questo esame o è interessato agli esercizi pubblicati dal prof?


Posted by kirka85 on 11-02-2011 09:50:

quindi di esercizi risolti non se ne trovano?
facciamo noi ( quelli che vogliano sostenere l'esame) un thread, in cui condividiamo le soluzioni degli esercizi

__________________
:bubble:


Posted by Vikyg13 on 13-02-2011 09:14:

Ti appoggio, sperando di non essere gli unici 2 interessati


Posted by kirka85 on 13-02-2011 19:01:

inizo a condividere la soluzione che ho trovato per l'esercizio 1, nn assicuro nulla, anzi spero che qualcuno posti qualche altra soluzione

code:
import calendar #Use isleap() to determine the next leap year. year=2011 check=True while check: if calendar.isleap(year): check=False print(year) year=year+1 #Find and use a function in module calendar to determine #how many leap years there will be #between the years 2000 and 2050, inclusive print(calendar.leapdays(2000, 2051)) #Find and use a function in module calendar to determine #which day of the week July 29, 2016 will be print(calendar.weekday(2016, 7, 29))

__________________
:bubble:


Posted by kirka85 on 13-02-2011 19:04:

code:
##Assign a list that contains the atomic numbers of the six alkaline earth metals -- beryllium (4), magnesium (12), calcium (20), ##strontium (38), barium (56), and radium (88) to a variable called alkaline_earth_metals. ## ## 1. Write code that returns the highest atomic number in alkaline_earth_metals. ## 2. Using one of the list methods, sort alkaline_earth_metals in ascending order (from the lightest to the heaviest). ## 3. Transform the alkaline_earth_metals into a dictionary using the name of the metals as the dictionary's key. ## 4. Create a second dictionary containing the noble gases -- helium (2), neon (10), argon (18), krypton (36), xenon (54), and radon (86) -- and stored in the variable noble_gases. ## 5. Merge the two dictionaries and print the result as couples (name, atomic number) sorted in ascending order on the element names. ## ##Note that Python's dictionaries do not preserve the insertion order neither it is sorted in some wa alkaline_earth_metals=[4,12,20,38,56,88] print (max(alkaline_earth_metals)) #1 alkaline_earth_metals.sort() print(alkaline_earth_metals) #2 alkaline_earth_metals_name=['beryllium', 'magnesium', 'calcium','strontium', 'barium', 'radium'] #3 metals_dict = dict(zip( alkaline_earth_metals_name, alkaline_earth_metals)) print (metals_dict) noble_gases=dict(helium=2, neon=10, argon=18, krypton=36, xenon=54, radon=86) #4 metals_dict.update(noble_gases) ordinamento=list(metals_dict.keys()) ordinamento.sort() for x in ordinamento: print ( x, metals_dict[x])

__________________
:bubble:


Posted by kirka85 on 13-02-2011 19:09:

code:
# Write a function that given a pure number prints a conversion table for it among any of the 8 scales #(remember that functions are objects as well). scale= dict(Kelvin=0.00 , Celsius=-273.15, Fahrenheit=-459.67, Rankine=0.0, Delisle=559.73, Newton=-90.14, Reaumur=-218.52, Romer=-135.9) def PrintConvertionTable (temperatura): print ('Valore inserito %f' % temperatura) print ('Tabella di conversione') for x in scale: print ('( %s, %f )' % (x, scale.get(x))) #Write a function that given a temperature in a specified scale returns a list of all the corresponding #temperatures in the other scales, the list must be sorted on the #temperature and the scale must be specified (hint: use a tuple). def ConvertionTable (temperatura, unita): if unita.lower() == 'kelvin': Conversione=fromKelvin(temperatura) Ordinamento(Conversione) elif unita.lower() == 'celsius': Conversione=fromCelsius(temperatura) Ordinamento(Conversione) else: print('Conversione per questa scala non implementata') def fromKelvin (K): Kelvin=K Celsius= (K - 273.15 ) Fahrenheit = (K*(9/5)-459.67) Rankine = K*(9/5) Delisle =(373.15 - K)*(3/2) Newton =(K - 273.15) * (33/100) Reaumur = (K - 273.15) * (4/5) Remer=(K - 273.15 )*(21/40) + 7.5 conv=dict(Kelvin= Kelvin, Celsius= Celsius, Fahrenheit=Fahrenheit, Rankine=Rankine, Delisle=Delisle, Newton=Newton, Reaumur=Reaumur, Remer=Remer) return conv def fromCelsius (C): Kelvin= C*(9/5) + 32 Celsius=C Fahrenheit = C + 273.15 Rankine = (C + 273.15)*(9/5) Delisle =(100-C)*(3/2) Newton = C*(33/100) Reaumur = C *(4/5) Remer= C* (21/40)+ 7.5 conv=dict(Kelvin= Kelvin, Celsius= Celsius, Fahrenheit=Fahrenheit, Rankine=Rankine, Delisle=Delisle, Newton=Newton, Reaumur=Reaumur, Remer=Remer) return conv def Ordinamento (ordinare): inverso=dict(zip(ordinare.values(),ordinare.keys())) #creo un dizionario invertando chiave valore ordinato=list(inverso.keys()) # creo una lista delle chiavi per poter ordinare ordinato.sort() for x in ordinato: print(x,inverso[x]) ##if __name__ == '__main__': ## #### print (ConvertionTable(5)) ## print (Fahrenheit(5))

__________________
:bubble:


Posted by kirka85 on 13-02-2011 19:11:

code:
##A matrix can be represented as a list of lists (rows and columns). ## ## 1. Use the comprehensions to describe the identity matrix (the one with all 0s but the 1s on the diagonal) of given size. ## 2. Use the comprehensions to describe a square matrix filled with the first n*n integers. ## 3. Write a function to transpose a generic matrix independently of the size and content. ## 4. Write a function to multiply two matrices non necessarily square matrix. import copy, numpy def IdentityMatrix (size): #1 identity=[[1 if i==member else 0 for i in range(size)] for member in range(size)] return identity def SquareMatrix (size): #2 squarem=[[(member*3+1+i)*(member*3+1+i) for i in range(size)] for member in range(size)] return squarem def TransposeSquare(matrice): #3 pero funziona solo quando la matrice è quadrata trasposta = copy.deepcopy(matrice) for i in range(len(matrice)): for j in range(len(matrice)): trasposta[j][i] = matrice[i][j] return trasposta def Transpose(matrice): #3 usando numpy trasposta=numpy.matrix(matrice).T return trasposta def MultiplyMatrix (m1,m2): #uso le funzionalità della libreria numpy a=numpy.matrix(m1) b=numpy.matrix(m2) rel=a*b return(rel) if __name__=='__main__': ## matrix=SquareMatrix(3) ## print (matrix) ## matrixT=TransposeSquare(matrix) ## print (matrixT)## ## r =MultiplyMatrix (matrix,matrixT) ## print (r) matrix=SquareMatrix(3) matrixT=Transpose(matrix) print (matrix) print (matrixT)


manca l'es.1.5
Ciao

__________________
:bubble:


Posted by Vikyg13 on 14-02-2011 13:02:

Ottimo! dammi 4 giorni di pausa da PA causa altro esame e posto anche io le soluzioni


Posted by Sacratix on 15-02-2011 17:45:

qualcuno mi manda la password, che non voglio chiederla di nuovo al profe >>

__________________
I wish for this night-time to last for a life-time


Posted by Vikyg13 on 21-02-2011 09:58:

Il primo esercizio l'ho fatto uguale con la differenza che calcola il prossimo anno bisestile a partire dall'anno corrente (che rileva da una funzione base python):

code:
import datetime import calendar def is_leap(): anno = datetime.date.today().year + 1 while calendar.isleap(anno) == False: anno += 1 return "Il prossimo anno bisestile e' il {0}".format(anno) def how_many_leap(): return calendar.leapdays(2000,2051) def which_day(): return calendar.weekday(2016,11,29)


All times are GMT. The time now is 10:13. Pages (4): [1] 2 3 4 »
Show all 46 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.