Skip to content
← Back to Community
US Capitals Quiz
Profile icon
BlueComet

Intro

Hi everyone, I just learned python at a summer camp and this is what I created for the final project. In this game you will have to guess the capitals of US states. You can play lots of times because I use random.choice() to give 10 randomized questions each time.

Rules

You have to guess the capital given the state. If you get it correct, your score will increase by 1.

How I made it

I used a text file for all the states and capitals of the US. But there was an extra city so I split it so it would only give the state and capital. Then I created a dictionary where the state is the key and the capital is the value.Then I created a function called game and used if and else to see if the input was the correct capital. And finally I added some colors using Ansi escape codes.

Voters
Profile icon
MH88
Profile icon
HenryZelonka1
Profile icon
CodingRobot12
Profile icon
BlueComet
Profile icon
zplusfour
Profile icon
AtticusKuhn
Profile icon
Roar123
Profile icon
DynamicSquid
Comments
hotnewtop
Profile icon
zplusfour

I know capitals, but not USA states capitals
I only know that USA's capital is washington
Cuz i am not from USA

Profile icon
BlueComet

@ZDev1 That's ok. Glad you liked it!

Profile icon
DynamicSquid

@ZDev1 I only know capital letters

Profile icon
zplusfour
Profile icon
zplusfour

@DynamicSquid XDXDXDXDXDXDXDXDXD

Profile icon
BlueComet

@DynamicSquid then you can use this to learn and then youll know both types of capitals

Profile icon
zplusfour
Profile icon
Roar123

Great job - the code quality is very good for someone who just learned python! I like the use of a dictionary to store the states and capitals.

Profile icon
BlueComet

@Roar123 Thanks!

Profile icon
jaronvesser

I feel like dying (your score is: 0
What is the capital of Minnesota: saint paul
Wrong! :(
St. Paul is the capital of Minnesota

Your score is: 0
What is the capital of Connecticut:
)

Profile icon
HahaYes

wait nebraska doesn't exist

Profile icon
BlueComet
Profile icon
HenryZelonka1

My life is complete.

image

Profile icon
HenryZelonka1

I'm actually not so bad now.
image

Profile icon
BlueComet

@HenryZelonka1 7 is really good!

Profile icon
HenryZelonka1

image

Profile icon
HenryZelonka1

image

Profile icon
HenryZelonka1

I'm addicted to this game.

Profile icon
HenryZelonka1

Beat that:

image

Profile icon
HenryZelonka1

My life is a lie:

image

Profile icon
HenryZelonka1

Finally,

image
(I'm not from the US)

Profile icon
zplusfour

Cool anyway