Posts

Showing posts with the label Python

In Python, Basic Shopping List Program

Image
Download

In Python, Tokenizing and Comparing Strings

Image
Download

In Python, Print Tokens In Reverse Order

Image
Download

In Python, list of random integers

Image
def change_list(src_list): # hold the middle 6 elements of the list dest_list = src_list[3:9] # use a slice to make a new list # Print the size print('The size of the list is now', len(dest_list)) # sort the new list in ascending order dest_list.sort() return dest_list def main(): # create an empty list my_list = [] from random import randrange # use a for loop to add 12 random integers for x in range(12): # all ranging from 50 to 100 my_list.append(randrange(50, 100)) # for loop to iterate over the list and display # all elements on one line separated by a single space. print('Here is the list of random integers...', end=' ') for x in my_list: print(x, end=' ') print() # display the 4th element print('The 4th element in the list is', my_list[3]) # the element at index 9 print('The element at index 9 is', my_list[9]) # the smallest element print('The smallest eleme...

In Python, Compute Grade Points Average

Image
Download

In Python, Validate If Email Really Exists

Image
Download