Skip to content

Instantly share code, notes, and snippets.

@NevadaKiran
Created March 11, 2015 04:08
Show Gist options
  • Save NevadaKiran/56a117143eac7d2887d1 to your computer and use it in GitHub Desktop.
Save NevadaKiran/56a117143eac7d2887d1 to your computer and use it in GitHub Desktop.
# Angola:
# id: AGO
# name: Angola
# population: 21,471,618
# capital: Luanda
# latitude: -8.81155
# longitude: 13.242
# income level: Upper Middle
# high income?: false
country_id = "AGO"
country_name = "Angola"
country_population = 21_471_618
country_capital = "Luanda"
country_latitude = -8.81155
country_longitude = 13.242
income_level = "Upper Middle"
country_high_income = false
puts country_name
puts "the population of #{country_name} is #{country_population}"
puts "the capital of #{country_name} is #{country_capital}"
# output the string "hight income" if income is high.
#if country_high_income == true
# puts "High Income"
#end
#puts "High Income" if country_high_income == true
if country_high_income == true
puts "high income"
else
puts "NOT Hight Income"
end
# output the country population if it is over 20 million
if country_population > 20_000_000
puts country_population
else
puts "There are less than 20 million people"
end
# check if > "high popultation if over 20 million.
# outbotu "medium populatin" if between 10 and 20 million
# output "low popultation if below 10 million
country_population = 10_000_000
if country_population > 20_000_000
puts "high population"
end
if country_population >= 10_000_000 && country_population <= 20_000_000
puts "medium population"
end
if country_population < 10_000_000
puts "low population"
end
# compatct veiw
high_population = country_population > 20_000_000
medium_population = country_population >=10_000_000 && country_population <= 20_000_000
low_population = country_population < 10_000_000
if country_population > 20_000_000
puts "high population"
elsif country_population >= 10_000_000 && country_population <= 20_000_000
puts "medium population"
elsif country_population < 10_000_000
puts "low population"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment