Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is Example 1-5
- '''
- Here we define a list of fruits
- '''
- fruits=['Peach', 'Grapes', 'Cherry', 'Orange']
- #Here we print the list of fruits
- print('Printing the list of fruits:')
- for index in range(len(fruits)):
- print(fruits[index], end=' ')
- #Here we print the line break
- print()
- #Here we define variable stop
- stop=20
- #Here we use range so that the start is 0, step is 1 and the limit is defined
- #by the value of variable stop
- for number in range(stop):
- print(str(number) + ' ', end="");
- print()
- #Here we define variable start
- start=-10
- #Here we use range so that the start is define by the value of variable start
- #and stop is defined by the value of variable stop. The step is default, 1.
- for number in range(start, stop):
- print(str(number)+' ', end="");
- print()
- #Here we define variable step
- step=3
- stop=10
- #Here we use range so that the start is define by the value of variable start
- #and stop is defined by the value of variable stop. The step is defined by the
- #value of variable step.
- for number in range(start, stop, step):
- print(str(number)+' ', end="");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement