It is a good programming practice to explain your functions by writing comments that describe what they do.
Answer:
program :
def separate_int_and_str(list_1):# function to seprate the list.
str_list=[] #list to hold the
int_list=[]#list which holds the integer value.
for x in list_1: #for loop to extract the list.
if(type(x)==str): #if condition to check the type of the element.
str_list.append(x)#create a list for the string value.
elif(type(x)==int): #check condition for th einteger value.
int_list.append(x)#create a list for the integer value.
Explanation:
- The above-defined function is written in the python language, which used the code to separate the list for integer and the string value.
- There are two lists define in the function which holds the integer and the string value separately.
- There is a 'for' loop which scans the element of the list and checks the list by the help of type function which tells the class of the element.
- Then if the type function states that the element is from the strong class, it will assign the element on the string list otherwise it assigns the element in the integer list.
In psuedocode it would be:
length = input()
width = input()
area = length * width
print(area + " sq ft");