File tree Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11# Write a program that reads the year of birth of a young person and informs, according to his age, whether he is
22# still going to enlist in the military service, whether it is the exact time to enlist or if it is past the
33# enlistment period. Your program should also show the time remaining or the time that has passed.
4-
54from datetime import date
65from xml .sax .handler import property_interning_dict
76
Original file line number Diff line number Diff line change 11# Improve challenge 61 by asking the user if he wants to show some more terms. The program will exit when he says he
22# wants to show 0 terms.
3+ print ("Arithmetic progression generator" )
4+ print ("-=-" * 20 )
5+ first_term = int (input ("Enter the first term:" ))
6+ reason = int (input ("Enter the reason of the arithmetic progression:" ))
7+ term = first_term
8+ counter = 1
9+ total = 0
10+ more = 10
11+ while more != 0 :
12+ total = more + total
13+ while counter <= total :
14+ print (f"{ term } " , end = ' ' )
15+ term += reason
16+ counter += 1
17+ print ("Pause" )
18+ more = int (input ("How many more terms do you want to show?" ))
Original file line number Diff line number Diff line change 1+ #Write a program that reads any integer number N and displays on the screen the first N elements of a
2+ # Fibonacci Sequence.
3+ terms = int (input ("How many terms do you want to show?" ))
4+ first_term = 0
5+ second_term = 1
6+ print (f"{ first_term } -> { second_term } " , end = '' )
7+ counter = 3
8+ while counter <= terms :
9+ third_term = first_term + second_term
10+ print (f" -> { third_term } " , end = '' )
11+ first_term = second_term
12+ second_term = third_term
13+ counter += 1
Original file line number Diff line number Diff line change 1+ #Create a program that reads several integers from the keyboard. The program will only stop when the user enters the
2+ # value 999, which is the stopping condition. At the end, show how many numbers were entered and what the sum of them
3+ # was (disregarding the flag).
4+ number = counter = amount = 0
5+ number = int (input ("Enter an integer [999 to stop]:" ))
6+ while number != 999 :
7+ amount += number
8+ counter += 1
9+ number = int (input ("Enter an integer [999 to stop]:" ))
10+ print (f"You enter { number } numbers and the sum between them is { amount } " )
You can’t perform that action at this time.
0 commit comments