Answer:
Keep it in the format
first one:
def swapping_stars():
line_str = ""
for line in range(6, 8):
for char in range(0, 6):
if line % 2 == char % 2:
line_str = line_str + "*"
else:
line_str = line_str + "-"
print(str(line_str))
swapping_stars()
second one:
if you want it to go:
23456
def print_numbers(list):
for i in range(1, len(list)):
print(str(list[i]))
num_list = [1, 2, 3, 4, 5, 6]
print_numbers(num_list)
if you want it to go
123456
def print_numbers(list):
doneONE = False
for i in range(1, len(list)):
if not doneONE:
print(str(list[i] - 1))
doneONE = True
print(str(list[i]))
num_list = [1, 2, 3, 4, 5, 6]
print_numbers(num_list)
Explanation:
Code:
population_china = 1420062022
population_india = 1368737513
years = 0
while population_china >= population_india:
population_china *= 1.0035
population_india *= 1.0108
years += 1
print(years)
Output:
6
Explanation:
Using a while loop would probably be of greater use than a for loop since we are increasing the population growth of both countries until India's population surpasses China's population (so a condition needs to be set).
Looking at the code, we first set the original population of both countries in their own variables (population_china, population_india). We also set the 'years' variable at 0, which will increase with respect to the yearly population growths of both countries. In the while loop, the condition population_china >= population_india will allow for the variable 'years' to increase until population_india surpasses population_china. Once India's population is larger than China's population, we are left with the number of years it takes for India's population to surpass China's population, which is 6 years.
Hope this helps :)
look up some facts about steam machines and then see when they were created and by who they were created and how they have evolved.