Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
Activity
JosvanderSpek
@JosvanderSpek
Nou ja ik wil gewoon dat op het moment dat de WOP (World's Oldest Person) iemand passeert, dat ze dan in de lijst oldest_people = [Jeanne, Sarah, ..., Jeralean, WOP] met die persoon van plek wisselt
Zodat de lijst daarna oldest_people = [Jeanne, Sarah, ..., WOP, Jeralean] is
JosvanderSpek
@JosvanderSpek
Het werkt iig!
JosvanderSpek
@JosvanderSpek
Dit snap ik dan weer niet
class Person:
def __init__(self, name, number, days_until, age):
self.name = name
self.number = number
self.days_until = days_until
self.age = age

class W_O_P:
name = WOP
number = oldest_people.index(name) + 1
def __init__(self, Birthday):
age = years
def days_until(self, Birthday):
daysTillBirthday = m.ceil((time.mktime(time.strptime("%i 07 06"%(nextBirthday + Birthday - (age + 1)),"%Y %m %d")) - now)/86400.0)
return daysTillBirthday
self.days_until = days_until(self, Birthday)
self.age = Birthday

class Bets:
def __init__(self, which_bet, days_until, zinnetje):
self.which_bet = which_bet
self.days_until = days_until
self.zinnetje = zinnetje

Jeanne         = Person(oldest_people[0], oldest_people.index(oldest_people[0]) + 1, daysTillJC, 122)
Sarah        = Person(oldest_people[1], oldest_people.index(oldest_people[1]) + 1, daysTillSK, 119)
Lucy            = Person(oldest_people[2], oldest_people.index(oldest_people[2]) + 1, daysTillLH, 117)
Marie_Louise= Person(oldest_people[3], oldest_people.index(oldest_people[3]) + 1, daysTillMLM, 117)
Misao       = Person(oldest_people[4], oldest_people.index(oldest_people[4]) + 1, daysTillMO, 117)
Maria       = Person(oldest_people[5], oldest_people.index(oldest_people[5]) + 1, daysTillMC, 116)
Gertrude    = Person(oldest_people[6], oldest_people.index(oldest_people[6]) + 1, daysTillGW, 116)
Tane        = Person(oldest_people[7], oldest_people.index(oldest_people[7]) + 1, daysTillTI, 116)
Elizabeth   = Person(oldest_people[8], oldest_people.index(oldest_people[8]) + 1, daysTillEB, 116)
Besse       = Person(oldest_people[9], oldest_people.index(oldest_people[9]) + 1, daysTillBC, 116)
Jiroemon    = Person(oldest_people[10], oldest_people.index(oldest_people[10]) + 1, daysTillJK, 116)
Jeralean    = Person(oldest_people[11], oldest_people.index(oldest_people[11]) + 1, daysTillJT, 116)
Bet_1       = Bets("Jos", daysVicNow, "days left in which I can win the bet!")
Bet_2       = Bets("Robert", daysVicNowRobert, "days left until Robert wins the bet!")
Death       = Bets("Death", daysTillDeathNow, "days left until she will reach the expected age of death.")

Oldest_People = [Jeanne, Sarah, Lucy, Marie_Louise, Misao, Maria, Gertrude, Tane, Elizabeth, Besse, Jiroemon, Jeralean, W_O_P(years)]
a = oldest_people.index(WOP)
A = Oldest_People.index(W_O_P(years))



Traceback (most recent call last):
File "Oldest People 4.4.3.py", line 137, in <module>
A = Oldest_People.index(W_O_P(years))
ValueError: <__main__.W_O_P object at 0x101de60f0> is not in list
Hoezo is W_O_P(years) not in list? Het is wel degelijk in list :p
Overigens is W_O_P(years) nu gelijk aan W_O_P(116)
Of moet ik echt een object instantiëren ofzo? Dat ik iets zeg als:
W_O_P_now = W_O_P_(years)
iambernie
@iambernie
Wanneer je voor de tweede keer een W_O_P object instantieert (in A = ...) dan is dit een ander object dan degene in Oldest_People. Python zal gelukkig niet voor jou veronderstellen dat deze twee objecten dezelfde zijn. Er zijn namelijk ook genoeg gevallen te bedenken waarin je wilt dat deze objecten anders zijn. In het stukje code hieronder zie je bijvoorbeeld dat de ene Foo(16) niet de ander is. Dat is te zien aan het geheugenadres (0x7f.....):
>>> class Foo:
...     def __init__(self, age):
...         self.age = age
...
>>> oldest = [Foo(16)]
>>> oldest[0]
<__main__.Foo object at 0x7f0920389ba8>
>>> Foo(16)
<__main__.Foo object at 0x7f09202e6c50>
>>> x = Foo(16)
>>> x
<__main__.Foo object at 0x7f09202e6828>
>>> oldest[0] == x
False
>>>
iambernie
@iambernie

Het is zelfs zo dat:

>>> Foo(16) == Foo(16)
False

Echter, dat het geheugenadres anders is, wil niet zeggen dat je er niet voor kunt zorgen dat iets alsFoo(16) == Foo(16) als nog als True wordt geevalueerd. Je zult dan moeten definieren wanneer twee objecten aan elkaar gelijk zijn. Dat doe je door __eq__ te definieren. Hieronder een voorbeeld:

>>> class Bar:
...     def __init__(self, age):
...         self.age = age
...     def __eq__(self, othr):
...         return self.age == othr.age
...
>>> x = Bar(16)
>>> y = Bar(16)
>>> x
<__main__.Bar object at 0x7f09202e6c88>
>>> y
<__main__.Bar object at 0x7f09202e6c50>
>>> x==y
True

>>> [Bar(10), x, Bar(12)].index(y)
1
JosvanderSpek
@JosvanderSpek
Alright, nice ouwe1
!*
iambernie
@iambernie
Je kan berichten trouwens 10 minuten nadat je ze hebt verstuurd nog corrigeren. (Zie knopjes "Reply", "Quote", "Edit", "Delete" aan de rechterkant van de berichten.)
JosvanderSpek
@JosvanderSpek
Haha ja weet ik, gewoon pijltje naar boven Kijk maar
JosvanderSpek
@JosvanderSpek
Kijk dit moet natuurlijk ook sneller kunnen....
def Surpassing(number, person, days_until, jaren) :
years_left = days_until//(365 + k)
days_left = days_until

if days_until > 366 :
days_left -=366
if days_until > (366 + 365) :
days_left -= 365
if days_until > (366 + 2*365) :
days_left -= 365
if days_until > (366 + 3*365) :
days_left -= 365
if days_until > (366 + 3*365 + 366) :
days_left -=366
if days_until > (366 + 3*365 +366 + 365) :
days_left -= 365
Maar die schrikkeldag is zooooooo kut jongen...
Maar dit is wel de eerste keer dat het gewoon écht klopt
JosvanderSpek
@JosvanderSpek
Oh ja, days_until is het totale aantal dagen tot een 'event' (e.g. 1087 dagen tot de 119e verjaardag). Maar ik wil het er hebben in de vorm '2 years and 358 days'. days_left moet in dit geval dan dus 358 opleveren.
EN DAT DOET HET EINDELIJK OOK
Maar het is wel lelijk
JosvanderSpek
@JosvanderSpek
Een while loopje misschien...??
JosvanderSpek
@JosvanderSpek
Ja! Zo!
    i = 0
while days_left >= 366 :
if i % 4 == 0 :
days_left -= 366
else :
days_left -= 365
i += 1
iambernie
@iambernie
schrikkeldagen... :(
JosvanderSpek
@JosvanderSpek
Ja echt vreselijk
Toch ontkom je er niet aan :p
JosvanderSpek
@JosvanderSpek
lower = [int(time.mktime(time.strptime("%i 02 29"%(leap_year),"%Y %m %d"))) for leap_year in list(4*np.arange(m.ceil(currentYear/4), 510))]
upper = [int(time.mktime(time.strptime("%i 03 01"%(leap_year + 1),"%Y %m %d"))) for leap_year in list(4*np.arange(m.ceil(currentYear/4), 510))]
JosvanderSpek
@JosvanderSpek
now = time.time()
currentYear = time.localtime(now)[0]
nextBirthday= currentYear
if now > time.mktime(time.strptime("%i 07 06 12"%(currentYear), "%Y %m %d %H")) :
nextBirthday += 1
next_birthday       = time.mktime(time.strptime("%i 07 06"%(nextBirthday),"%Y %m %d"))

lower = [int(time.mktime(time.strptime("%i 02 29"%(leap_year),"%Y %m %d"))) for leap_year in list(4*np.arange(m.ceil(currentYear/4), 510))]
upper = [int(time.mktime(time.strptime("%i 03 01"%(leap_year + 1),"%Y %m %d"))) for leap_year in list(4*np.arange(m.ceil(currentYear/4), 510))]

days_per_year = 365
for i in range(3) :
if (next_birthday in range(lower[i], upper[i])) and (now < lower[0]) :
days_per_year = 366
iambernie
@iambernie
>>> b=0
>>> if 1 < b < 3:
...     print("ok")
...
>>> b=2
>>> if 1 < b < 3:
...     print("ok")
...
ok
JosvanderSpek
@JosvanderSpek
>>> if (x == 23) | (x == 10) :
...     print('yes')
...
yes
iambernie
@iambernie

>>> True|True
True
>>> True|False
True
>>> False|False
False
>>> False|2
2
>>> 2|2
2
>>> 2 | 2
2
>>> 2 | 3
3
>>> 2 | 4
6
>>>
iambernie
@iambernie
>>> 5 | 3
7
>>> 5 or 3
5
JosvanderSpek
@JosvanderSpek
def print_status(which_bet, years_till_victory, days_left, total_days_bet, percentages, zin, Universal_time):

if years_till_victory == 1 : jaarjaren = "year"
else : jaarjaren = "years"
if days_left == 1 : dagdagen = "day"
else : dagdagen = "days"

stats = ["\n\n " + str(int(daysRounded)) + " of the %i days"%(total_days_bet), "for Robert", "to endure", "(" + str(round(percentages, 3)) + "%)", "have already passed, so victory", zin, str(int(years_till_victory)), jaarjaren, "and", str(int(days_left)), dagdagen, "!\n\n"]

if years_till_victory < 1 :
for i in range(3): stats.pop(6)                                                                                                                 # Waarom werkt stats.pop(3) for j in range(3) niet?
if which_bet == "Jos" :
stats.pop(1)

stats_line = " ".join(stats)
Universe_comparison = " In comparison to the current age of the Universe, currently estimated at around 13 milliard 798 million years, the Universe would now be " + format(int(Universal_time), ',d') + " years old.\n\n"

if years_till_victory < 1 :
stats.pop(6) for j in range(3)                                                                                                                 # Waarom werkt stats.pop(6) for j in range(3) niet?
if which_bet == "Jos" :
stats.pop(1)
iambernie
@iambernie
>>> lijst
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> del lijst[4:7]
>>> lijst
[1, 2, 3, 4, 8, 9, 10]
JosvanderSpek
@JosvanderSpek
25 of the 116 days to endure (20.951%) have already passed, so victory can yet be mine for another 91 days !

In comparison to the current age of the Universe, currently estimated at around 13 milliard 798 million years, the Universe would now be 2,890,786,051 years old.

--------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

25 of the 191 days for Robert to endure (12.724%) have already passed, so victory shall be his in 166 days !

In comparison to the current age of the Universe, currently estimated at around 13 milliard 798 million years, the Universe would now be 1,755,660,638 years old.

---------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`
Ik ga een nachtje door :p
Het weer laat het toe
iambernie
@iambernie
Goedemorgen! :D
haha
JosvanderSpek
@JosvanderSpek
Hey pik
iambernie
@iambernie
Hey G