...
protos=deuteros - 1.0/4 --Εδω διαιρεσα πραγματικο και οχι ακεραιο με το 4 γιατι αλλιως μου εβγαζε 1/4=0
...
...πρέπει να μην χρησιμοποιείς python 3 τότε ...
Στην python 3 γίνεται true διαίρεση ... :
- >>> 1/4
0.25
...
protos=deuteros - 1.0/4 --Εδω διαιρεσα πραγματικο και οχι ακεραιο με το 4 γιατι αλλιως μου εβγαζε 1/4=0
...
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#Υπάρχουν 3 τύποι μεταβλητών, Long, Integer, String
#Άσκηση 2
metavliti21 =" Έχεις καμιά ιδέα πού να πάμε;"
print(metavliti21)
metavliti22 = 'Ναι, ας πάμε στο Καφεωδείο "ΟΡΦΕΑΣ".'
print(metavliti22)
metavliti23 = "Αυτό είναι \"παράδειγμα\" 'χρήσης' πολλών εισαγωγικών."
print(metavliti23)
#Άσκηση 3
metavliti31 = metavliti21 + "\n\n" + metavliti22
print(metavliti31)
#Άσκηση 5
ilikia=20
onoma="Ανδρέας"
print("Ο {0} είναι {1} χρονών".format(onoma,ilikia))
#Άσκηση 6
for i in range(1,6):
if i == 5:
print("Ο αριθμός 5 υπάρχει στη σύνολο")
break
if i != 5:
print("Ο αριθμός 5 δεν υπάρχει στο σύνολο)
#Άσκηση 7
deuteros = 1.75
protos = deuteros - (deuteros / 4)
tritos = ((protos + deuteros) / 3) + 1
tetartos = (tritos - protos) + 2
print ("deuteros = "deuteros)
print ("protos = "protos)
print ("tritos = "tritos)
print ("tetartos = "tetartos)
pemptos = (3.5**2) - protos - deuteros - tritos - tetartos
print ("pemptos = "pemptos)
sokoban4ever έγραψε:@hoffman...
protos=deuteros - 1.0/4 --Εδω διαιρεσα πραγματικο και οχι ακεραιο με το 4 γιατι αλλιως μου εβγαζε 1/4=0
...
...πρέπει να μην χρησιμοποιείς python 3 τότε ...
Στην python 3 γίνεται true διαίρεση ... :>>> 1/4
0.25
zirico έγραψε:Έκανα και εγώ σήμερα τις ασκήσεις με λίγο καθυστέρηση και πάω για την θεωρία του δευτερου μαθήματος, απλά δεν βρήκα που αναφέρεται στην ύλη μας, η απάντηση στην ερώτηση 6. Ευχαριστώ!
2009-06-15:
- Αφαιρέθηκε η ερώτηση 5.2 λόγω λάθους εκφώνησης!!
- Άλλαξα τη διατύπωση της ερώτησης 6! (είναι λιγάκι εκτός μαθήματος)
print("Protos = {0:.3} m\nDeuteros = {1:.3} m\nTritos = {2:.3} m\n\
Tetartos = {3:.3} m\nPemptos = {4:.3} m".format(protos, deuteros, tritos,
tetartos, pemptos))
'{0:.3}'.format(1/3)
Each replacement field contains either the numeric index of a positional argument, or the name of a keyword argument.
For non-number types the field indicates the maximum field size - in other words, how many characters will be used from the field content. The precision is not allowed for integer values.
>>> x='13.3333390'
>>> '{0:.0}'.format(x)
''
>>> '{0:.1}'.format(x)
'1'
>>> '{0:.2}'.format(x)
'13'
>>> '{0:.3}'.format(x)
'13.'
>>> '{0:.4}'.format(x)
'13.3'
>>> '{0:.5}'.format(x)
'13.33'
>>> '{0:.6}'.format(x)
'13.333'
>>> '{0:.7}'.format(x)
'13.3333'
>>> '{0:.8}'.format(x)
'13.33333'
>>>