python quisito.
  • In diretta da GamesVillage.it
    • News
    • -
    • In Evidenza
    • -
    • Recensioni
    • -
    • RetroGaming
    • -
    • Anteprime
    • -
    • Video
    • -
    • Cinema

Pag 1 di 2 12 UltimoUltimo
Visualizzazione risultati da 1 a 15 di 21

Discussione: python quisito.

Cambio titolo
  1. #1
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643

    python quisito.

    ciao a tutti,
    volevo chiedervi che comando si usa per fare in modo che un programma ricominci da capo. cioe fare in modo che dopo che finisca si restarti automaticamente.
    grazie.
    Niente link a siti hentai nella firma.

  2. #2
    fremo di raccapriccio L'avatar di kocam
    Registrato il
    10-02
    Località
    Dove vivi
    Messaggi
    3.463
    richiamare la funziona principale alla fine? o_o
    Sono masto. Gaio chi nega.

  3. #3
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    come?
    Niente link a siti hentai nella firma.

  4. #4
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    forse nn sono stato abbastanza chiaro....
    sono estremamente noob.
    Niente link a siti hentai nella firma.

  5. #5
    Utente L'avatar di Phoenix
    Registrato il
    10-02
    Località
    Midwich Street
    Messaggi
    6.699
    Fai un ciclo infinito.
    O fai un while che dice di uscire solo se l'utente dà un determinato input.
    Se spieghi meglio la natura del programma in questione è più facile consigliarti...


    He who is not bold enough to be stared at from across the abyss
    is not bold enough to stare into it himself.

  6. #6
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    ok ecco
    Codice:
    print "welcome to the area calculation program By: Kareem kamel"
    print "----------------------------------------------------------"
    
    
    print """
    plz choose a shape:
    1- for triangle
    2- for circle
    3- for square
    
    or press 4 to quit
    """
              
    shape= raw_input("plz select the shape u desire: ")
    if shape== "1":
        base=input("plz eneter the triangle's base lenght")
        height=input("plz enter the triangle's height")
        area= (base*height)/2
        print "the triangle's area is equale to:", area
    elif shape== "2":
        radius=input("plz enter the radius:")
        area= 3.14189*radius*radius
        print "the circle's area is equal to:",area
    elif shape=="3":
        side=input("what's the square's side lenght?")
        area= side**2
        print"the square's side lenght is equal to", area
    elif shape=="4":
    import sys
    sys.exit()
    else:
        print " this aint no valid comand U idiot"
    ok diciamo che io voglia fare in modo che finche l'utente nn sceglie l'opzione quit il programma continui a ripetersi, cosa devo fare??
    Niente link a siti hentai nella firma.

  7. #7
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    PS: ci potrebbe essere un errore nel modulo sys se qualcuno potrebbe corregierlo mi farebbe un piacere.
    Niente link a siti hentai nella firma.

  8. #8
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    avrei un altra domanda.
    nn ho ancora capito a che cosa serve la funzione "return".
    perfavore spiegatemi!!!!
    Niente link a siti hentai nella firma.

  9. #9
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    scusate tanto ma mentre ci sono vorrei che mi spiegaste come questi due moduli funzionano:
    Codice:
    # a day value of -1 => today
    def dayOfWeek(DayNum = -1):
        days = ['Monday','Tuesday',
                'Wednesday','Thursday', 
                'Friday', 'Saturday', 'Sunday']
                    
        # check for the default value        
        if DayNum == -1:
            # Use the time module functions to get current time
            # see the table above and the official module documentation
            import time
            theTime = time.localtime(time.time())
            DayNum = theTime[6]
        return days[DayNum]
    Codice:
    def numwords(s):
        list = split(s) # list with each element a word
        return len(list) # return number of elements in list
    
    for line in file:
        total = total + numwords(line) # accumulate totals for each line
    print "File had %d words" % total
    in dettagli plz!!
    grazie!
    Niente link a siti hentai nella firma.

  10. #10
    Utente
    Registrato il
    10-02
    Messaggi
    2.367
    Codice:
    print "welcome to the area calculation program By: Kareem kamel"
    print "----------------------------------------------------------"
    
    
    print """
    plz choose a shape:
    1- for triangle
    2- for circle
    3- for square
    
    or press 4 to quit
    """
    
    while (1): 
    	shape= raw_input("plz select the shape u desire: ")
    	if shape== "1":
        		base=input("plz eneter the triangle's base lenght")
        		height=input("plz enter the triangle's height")
        		area= (base*height)/2
        		print "the triangle's area is equale to:", area
    	elif shape== "2":
        		radius=input("plz enter the radius:")
        		area= 3.14189*radius*radius
        		print "the circle's area is equal to:",area
    	elif shape=="3":
        		side=input("what's the square's side lenght?")
        		area= side**2
        		print"the square's side lenght is equal to", area
    	elif shape=="4":
        		break
    	else:
        		print " this aint no valid comand U idiot"
    Il problema non era nel sys, ma nell'indentazione........

    RETURN: Prima di capire a che cosa serve il return, sei sicuro di aver capito a come funziona una funzione??

    MODULO: Quale modulo ???

  11. #11
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    ma per uscire dal programma nn si fa
    import sys
    sys.exit
    ??
    si ho capito come funziona una funzione ma nn capisco che significato abbia il comando return???
    e perfavore cercate di spiegarmi quei due esempi.
    Niente link a siti hentai nella firma.

  12. #12
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    Citazione Yubei
    Codice:
    print "welcome to the area calculation program By: Kareem kamel"
    print "----------------------------------------------------------"
    
    
    print """
    plz choose a shape:
    1- for triangle
    2- for circle
    3- for square
    
    or press 4 to quit
    """
    
    while (1): 
    	shape= raw_input("plz select the shape u desire: ")
    	if shape== "1":
        		base=input("plz eneter the triangle's base lenght")
        		height=input("plz enter the triangle's height")
        		area= (base*height)/2
        		print "the triangle's area is equale to:", area
    	elif shape== "2":
        		radius=input("plz enter the radius:")
        		area= 3.14189*radius*radius
        		print "the circle's area is equal to:",area
    	elif shape=="3":
        		side=input("what's the square's side lenght?")
        		area= side**2
        		print"the square's side lenght is equal to", area
    	elif shape=="4":
        		break
    	else:
        		print " this aint no valid comand U idiot"
    Il problema non era nel sys, ma nell'indentazione........

    RETURN: Prima di capire a che cosa serve il return, sei sicuro di aver capito a come funziona una funzione??

    MODULO: Quale modulo ???
    grazie per avere corretto il programma.
    scusa ho sbaliata tra modulo e funzione
    Niente link a siti hentai nella firma.

  13. #13
    Utente L'avatar di Phoenix
    Registrato il
    10-02
    Località
    Midwich Street
    Messaggi
    6.699
    Citazione tricky
    ma per uscire dal programma nn si fa
    import sys
    sys.exit
    ??
    si ho capito come funziona una funzione ma nn capisco che significato abbia il comando return???
    e perfavore cercate di spiegarmi quei due esempi.
    Il comando return assegna un valore a una funzione... non c'è granchè da capire. Cosa c'è di poco chiaro in questo esempio?


    He who is not bold enough to be stared at from across the abyss
    is not bold enough to stare into it himself.

  14. #14
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    Citazione Phoenix
    Il comando return assegna un valore a una funzione... non c'è granchè da capire. Cosa c'è di poco chiaro in questo esempio?
    nn capisco mi dispiace...
    perfavore si piu chiaro.
    aparte il fatto che nn so che linguaggio sia quello usato nel esempio.
    allora diciamo cosa cambia quando fai return e quando non lo metti

    mi dispiace abbiate un po di pazienza
    Niente link a siti hentai nella firma.

  15. #15
    Pervert L'avatar di tricky
    Registrato il
    11-03
    Località
    EGypt
    Messaggi
    1.643
    uhm ok ho capito scusate la mia stupidita.
    mi fareste un grandissimo piacere a spiegarmi i due esmpi grazie
    Niente link a siti hentai nella firma.

Pag 1 di 2 12 UltimoUltimo

Regole di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  •