Answer:
- country_pop = {
- 'China': 1365830000,
- 'India': 1247220000,
- 'United States': 318463000,
- 'Indonesia': 252164800
- }
- for key in country_pop:
- print(key + " has " + str(country_pop[key]) + " people")
Explanation:
The solution code is written in Python 3.
Given a dictionary, country_pop with data that includes four country along with their respective population (Line 1-6). We can use for in loop structure to traverse through each of the key (country) in the dictionary and print their respective population value (Line 7-8). The general loop structure through is as follow:
for key in dict:
do something
One key will be addressed for each round of loop and we can use that key to extract the corresponding value of the key (e.g. country_pop[key]) and print it out.
Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm
Answer:
#include <stdio.h>
int main()
{
int x;
float y;
printf("Input total distance in km: ");
scanf("%d",&x);
printf("Input total fuel spent in liters: ");
scanf("%f", &y);
printf("Average consumption (km/lt) %.3f ",x/y);
printf("\n");
return 0;
}
In Python, assume that a file containing a series of integers is named numbers.txt and exist on the computer's disk. Write a program that reads the entire numbers store in the file and calculates their total.
Here is what I have written but it does not run:
def. main():
out file=open('numbers.txt','r')
temp=outfile.readline()
total=0
while temp!='':
t=int(temp)
total=total+i
temp=outfile.readline()
outfile.close()
print('Total sum is:',total)
main()
Text file is a file named numbers.txt with the numbers 1-50 in it
Learn more:
- The sum of three consecutive integers is 186. what are the integers
brainly.com/question/1768254
Keywords: python, integers, computer, numbers, program
The 20th century seemed to be the year of a complete freedom once the Internet has been spread worldwidely. Unfortunately, it only seemed to be a trial to see various reactions. The 21st century will change this gradually.