>>>line="Citadel Morning News. News about the Citadel in the morning, pretty self explanatory.">>>m=line.split()>>>m['Citadel','Morning','News.','News','about','the','Citadel','in','the','morning,','pretty','self','explanatory.']
importsyllables#user_input = "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness."#user_input = "There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened."user_input=str(input("Enter a paragraph => ")).strip()print(user_input)# Calculate ASLsentences=user_input.split(". ")words_per_sentence=[]#print(sentences)forsentenceinsentences:words=sentence.split()words_per_sentence.append(len(words))asl=sum(words_per_sentence)/len(words_per_sentence)#print(asl)# Calculate PHWwords=user_input.split()#print(len(words))#find hard wordshard_words=[]forwordinwords:num_syllables=syllables.find_num_syllables(word)#print(num_syllables)ifnum_syllables>=3and"-"notinwordandword[-2:]!="es"andword[-2:]!="ed":#print(words)hard_words.append(word)#print(hard_words)#print(hard_words)#print(len(hard_words))#print(words)#print(len(words))phw=len(hard_words)/len(words)*100# Calculate ASYLtotal_syllables=0forwordinwords:total_syllables+=syllables.find_num_syllables(word)asyl=total_syllables/len(words)# Caclulate GFRIgfri=0.4*(asl+phw)# Calculate FKRIfkri=206.835-1.015*asl-86.4*asylprint("Here are the hard words in this paragraph:\n"+str(hard_words))print("Statistics: ASL:{:.2f} PHW:{:.2f}% ASYL:{:.2f}".format(asl,phw,asyl))print("Readability index (GFRI): {:.2f}".format(gfri))print("Readability index (FKRI): {:.2f}".format(fkri))
# Get user inputnum_turn=int(input("How many turns? => ").strip())print(num_turn)pikachu_name=str(input("What is the name of your pikachu? => ").strip())print(pikachu_name)often_turn=int(input("How often do we see a Pokemon (turns)? => ").strip())print(str(often_turn)+"\n")position=(75,75)wins,losses,no_pokemon=0,0,0turn_counter=0records=[]last_direction=""# Debugging#num_turn = 5#print(num_turn)#pikachu_name = "Piki"#print(pikachu_name)#often_turn = 1#print(often_turn)defmove_pokemon(coords,direction,steps):globalpositionx,y=coordsdirection=direction.lower()ifdirectionin['n','s','e','w']:ifdirection=='n':x=max(0,x-steps)elifdirection=='e':y=min(150,y+steps)elifdirection=='s':x=min(150,x+steps)elifdirection=='w':y=max(0,y-steps)position=(x,y)defwalk(repeat):globalturn_counter,last_directionfor_inrange(repeat):direction=input("What direction does "+pikachu_name+" walk? => ").strip()print(direction)direction=direction.lower()ifdirectionin['n','s','e','w']:move_pokemon(position,direction,5)last_direction=directionturn_counter+=1defturn_message(turn_counter,position):print("Turn "+str(turn_counter)+", "+pikachu_name+" at "+str(position))defbattle(pokemon_type):globalrecords,position,last_directionifpokemon_type.lower()=='g':records.append('Lose')opposite_directions={'n':'s','s':'n','e':'w','w':'e'}move_pokemon(position,opposite_directions[last_direction],10)print(pikachu_name+" runs away to "+str(position))elifpokemon_type.lower()=='w':records.append('Win')move_pokemon(position,last_direction,1)print(pikachu_name+" wins and moves to "+str(position))else:records.append('No Pokemon')print("Starting simulation, turn 0 "+pikachu_name+" at (75, 75)")foriinrange(num_turn//often_turn):walk(often_turn)turn_message(turn_counter,position)pokemon_type=input("What type of pokemon do you meet (W)ater, (G)round? => ").strip()print(pokemon_type)battle(pokemon_type)ifnum_turn<often_turn:foriinrange(num_turn):direction=input("What direction does "+pikachu_name+" walk? => ").strip()print(direction)direction=direction.lower()ifdirectionin['n','s','e','w']:move_pokemon(position,direction,5)last_direction=directionturn_counter+=1print(pikachu_name+" ends up at "+"("+str(position[0])+", "+str(position[1])+")"+", Record: "+str(records))
importmathn_bear=input("Number of bears => ").strip()print(n_bear)n_size=input("Size of berry area => ").strip()print(n_size)n_bear=int(n_bear)n_size=float(n_size)year=10block_size=10data=[]title=["Year","Bears","Berry","Tourists"]defprint_line(b1,b2,b3,b4):b1=b1+" "*int(10-len(b1))b2=b2+" "*int(10-len(b2))b3=b3+" "*int(10-len(b3))b4=b4+" "*int(10-len(b4))print(b1+b2+b3+b4)defshow_data(data):data_copy=data.copy()forlineindata_copy:line[2]="{:.1f}".format(float(line[2]))line=[str(i)foriinline]print_line(line[0],line[1],line[2],line[3])defconclusion(data):#print(data)initial_line=data[0]max_bears,max_berry,max_tourists=initial_line[1],float(initial_line[2]),initial_line[3]min_bears,min_berry,min_tourists=initial_line[1],float(initial_line[2]),initial_line[3]foriindata:max_bears=max(max_bears,i[1])max_berry=max(max_berry,float(i[2]))max_tourists=max(max_tourists,i[3])min_bears=min(min_bears,i[1])min_berry=min(min_berry,float(i[2]))min_tourists=min(min_tourists,i[3])message=[]message.append(["Min:",str(min_bears),str(min_berry),str(min_tourists)])message.append(["Max:",str(max_bears),str(max_berry),str(max_tourists)])show_data(message)deffind_next(bears,berry,tourists):bears_next=berry/(50*(bears+1))+bears*0.60-(math.log(1+tourists,10)*0.1)berries_next=(berry*1.5)-(bears+1)*(berry/14)-(math.log(1+tourists,10)*0.05)ifberries_next<0:berries_next=0return(int(bears_next),berries_next)deffind_tourists(bears):bears=int(bears)ifbears<4orbears>15:tourists=0elifbears<=10:tourists=10000*bearselifbears>10:tourists=100000+20000*(bears-10)returntouristsforiinrange(year):tourists=find_tourists(n_bear)data.append([i+1,n_bear,n_size,tourists])n_bear,n_size=find_next(n_bear,n_size,tourists)print_line(title[0],title[1],title[2],title[3])show_data(data)print()conclusion(data)