Skip to main content

Le capitali degli Stati Uniti



Ok, per una volta facciamo un post in italiano. In questa occasione, presentiamo una version, in italiano, del test sulle capitali degli USA. c'è qualche piccola differenza rispetto alla versione in inglese. Qui c'è un correttore alla fine e c'è un po' di controllo sull'articolo... si sa la lingua italiana è più complicata di quella inglese.

So, this is a version for the italians... of the test about USA capitals, it is a little bit different from the english version. I had to solve the issues with the article before the name of the state. Italian language is complex, as you may know...

from random import shuffle as mischia

capitale = {'Alabama': 'Montgomery', 
       'Alaska': 'Juneau', 
       'Arizona': 'Phoenix', 
       'Arkansas': 'Little Rock', 
       'California': 'Sacramento', 
       'Colorado': 'Denver', 
       'Connecticut': 'Hartford', 
       'Delaware': 'Dover', 
       'Florida': 'Tallahassee', 
       'Georgia': 'Atlanta', 
       'Hawaii': 'Honolulu', 
       'Idaho': 'Boise', 
       'Illinois': 'Springfield', 
       'Indiana': 'Indianapolis', 
       'Iowa': 'Des Moines', 
       'Kansas': 'Topeka', 
       'Kentucky': 'Frankfort', 
       'Louisiana': 'Baton Rouge', 
       'Maine': 'Augusta', 
       'Maryland': 'Annapolis', 
       'Massachusetts': 'Boston', 
       'Michigan': 'Lansing', 
       'Minnesota': 'Saint Paul', 
       'Mississippi': 'Jackson', 
       'Missouri': 'Jefferson City', 
       'Montana': 'Helena', 
       'Nebraska': 'Lincoln', 
       'Nevada': 'Carson City', 
       'New Hampshire': 'Concord', 
       'New Jersey': 'Trenton', 
       'New Mexico': 'Santa Fe', 
       'New York': 'Albany', 
       'North Carolina': 'Raleigh', 
       'North Dakota': 'Bismarck', 
       'Ohio': 'Columbus', 
       'Oklahoma': 'Oklahoma City', 
       'Oregon': 'Salem', 
       'Pennsylvania': 'Harrisburg', 
       'Rhode Island': 'Providence', 
       'South Carolina': 'Columbia', 
       'South Dakota': 'Pierre', 
       'Tennessee': 'Nashville', 
       'Texas': 'Austin', 
       'Utah': 'Salt Lake City', 
       'Vermont': 'Montpelier', 
       'Virginia': 'Richmond', 
       'Washington': 'Olympia', 
       'West Virginia': 'Charleston', 
       'Wisconsin': 'Madison', 
       'Wyoming': 'Cheyenne'}


print("Test sulle capitali degli Stati Uniti\n")

stato = []
correttore = []
for state in capitale:
    stato += [state]

mischia(stato)

risposte = [capitale[i] for i in stato]
#print(risposte)

x = 1
for n in range(30):
    # di New York di Washington
    if stato[n] == ("New York") or stato[n]== ("Washington"):
        articolo = "di"
    elif stato[n][0] in "AEIO":
        articolo = "dell\'"
    elif stato[n][0] in "H":
        articolo = "delle"
    elif stato[n][0] in "U" or stato[n] == "Iowa":
        articolo = "dello"
    elif stato[n] == "California" or stato[n]=="Giorgia" or stato[n]=="Virginia" or stato[n]=="Florida" or stato[n]=="Pennsylvania" or stato[n]=="Lousiana":
        articolo = "della"
    else:
        articolo = "del"
    
    print(x,"\nQual è la capitale",articolo, stato[n]+ "?")
    print("--------------------------------")
    giusta = risposte[n]
    r_copy = risposte.copy()
    r_copy.pop(n)
    mischia(r_copy)
    ris = []
    for i in range(3):
        ris += [r_copy[i]]
    ris += [giusta]
    mischia(ris)
    for i in range(4):
        print(ris[i])
    print()
    correttore += [str(x)+"\\"+str(ris.index(giusta)+1)]
    x +=1

for n in correttore:
    print(n,end="  ")
Test sulle capitali degli Stati Uniti

1 
Qual è la capitale dell' Indiana?
--------------------------------
Indianapolis
Albany
Springfield
Santa Fe

2 
Qual è la capitale del Kansas?
--------------------------------
Columbus
Frankfort
Cheyenne
Topeka

3 
Qual è la capitale dell' Arkansas?
--------------------------------
Topeka
Boston
Dover
Little Rock

4 
Qual è la capitale del Minnesota?
--------------------------------
Little Rock
Saint Paul
Springfield
Columbus

5 
Qual è la capitale dell' Oklahoma?
--------------------------------
Indianapolis
Tallahassee
Oklahoma City
Albany

6 
Qual è la capitale del Missouri?
--------------------------------
Indianapolis
Olympia
Jefferson City
Phoenix

7 
Qual è la capitale del Rhode Island?
--------------------------------
Denver
Augusta
Carson City
Providence

8 
Qual è la capitale del New Mexico?
--------------------------------
Montpelier
Tallahassee
Atlanta
Santa Fe

9 
Qual è la capitale del New Jersey?
--------------------------------
Boise
Jefferson City
Trenton
Santa Fe

10 
Qual è la capitale dell' Oregon?
--------------------------------
Des Moines
Harrisburg
Santa Fe
Salem

11 
Qual è la capitale del Tennessee?
--------------------------------
Dover
Topeka
Des Moines
Nashville

12 
Qual è la capitale dell' Illinois?
--------------------------------
Bismarck
Lansing
Springfield
Dover

13 
Qual è la capitale del North Carolina?
--------------------------------
Raleigh
Pierre
Little Rock
Providence

14 
Qual è la capitale della Florida?
--------------------------------
Tallahassee
Trenton
Juneau
Helena

15 
Qual è la capitale del Maryland?
--------------------------------
Annapolis
Sacramento
Phoenix
Frankfort

16 
Qual è la capitale del Vermont?
--------------------------------
Annapolis
Boise
Olympia
Montpelier

17 
Qual è la capitale della Pennsylvania?
--------------------------------
Providence
Harrisburg
Richmond
Jackson

18 
Qual è la capitale del Texas?
--------------------------------
Lansing
Nashville
Austin
Jefferson City

19 
Qual è la capitale dell' Idaho?
--------------------------------
Tallahassee
Pierre
Boise
Augusta

20 
Qual è la capitale del Louisiana?
--------------------------------
Baton Rouge
Juneau
Sacramento
Harrisburg

21 
Qual è la capitale del Montana?
--------------------------------
Pierre
Saint Paul
Nashville
Helena

22 
Qual è la capitale dell' Alabama?
--------------------------------
Montgomery
Juneau
Charleston
Lansing

23 
Qual è la capitale del West Virginia?
--------------------------------
Olympia
Juneau
Cheyenne
Charleston

24 
Qual è la capitale del Delaware?
--------------------------------
Madison
Topeka
Charleston
Dover

25 
Qual è la capitale del Wisconsin?
--------------------------------
Madison
Columbus
Boston
Phoenix

26 
Qual è la capitale del Nevada?
--------------------------------
Concord
Boston
Carson City
Tallahassee

27 
Qual è la capitale dell' Ohio?
--------------------------------
Baton Rouge
Trenton
Nashville
Columbus

28 
Qual è la capitale del North Dakota?
--------------------------------
Dover
Austin
Hartford
Bismarck

29 
Qual è la capitale dell' Arizona?
--------------------------------
Des Moines
Salem
Annapolis
Phoenix

30 
Qual è la capitale di Washington?
--------------------------------
Olympia
Montpelier
Carson City
Honolulu

1\1  2\4  3\4  4\2  5\3  6\3  7\4  8\4  9\3  10\4  11\4  12\3  13\1  14\1  15\1  16\4  17\2  18\3  19\3  20\1  21\4  22\1  23\4  24\4  25\1  26\3  27\4  28\4  29\4  30\1  


Comments

Popular posts from this blog

Widgets for Jupyter Notebook: a text input widget

Widgets for Jupyter notebook ¶ Let's import the module ipywidgets into the Jupyter Notebook from ipywidgets import widgets from ipywidgets import * from traitlets import * Now we import the display function from IPython ¶ let's attach a function to the event on_submit After we run this cell, we can go up and write something in the text widget and after you submit the text you wrote will be printed after the cell from IPython.display import display text = widgets . Text () display ( text ) def handle_submit ( sender ): print ( "Thank you for entering this text:" , text . value ) text . on_submit ( handle_submit ) Thank you for entering this text: Ciao

Image in Jupyter and PIL step by step

Hi, """ Hi, we will see a step by step tutorial about PIL and IPython.core.display modules to create images from other images and diplaying them in Jupyter notebook """ # What we will do # Create a card # 1. Take a pic of a heart # 2. Create an image blanck the size of a card 90*130 # 3. Paste the heart in the middle # 4. show the card """ As first step wi will simply display an image on the notebook. I will show two way to display the image with 'display' from IPhyton a. Using the open method of PIL.Image (named Img) b. Using the Image method from the IPython.core.display module """ # 1. Take the pic of a heart from IPython.core.display import Image , display from PIL import Image as Img heart = 'img/heart.png' display ( Image ( heart )) display ( Img . open ( heart )) # 2. Create an image blanck the size of a card 90*130 # 3. Paste the heart in the middle #...

Let's draw a circle with PIL in Python

Let's continue making our coding around PIL. Let's start with some basic drawing: a circle from PIL import Image , ImageDraw img = Image . new ( "RGB" ,( 60 , 60 ), 'white' ) dr = ImageDraw . Draw ( img ) dr . ellipse (( 0 , 0 , 60 , 60 ), 'yellow' ) img . show () this is the image produced *If you use jupyter notebook, just write img at the end to see the output.