return

Need to write a function that returns all of the vowels in a word

Need to write a function that returns all of the vowels in a word Question: I am new to learning python and am struggling to create a Function to return a string only of vowels from word no matter if its a blank string, string with no vowels, or string with all vowels. This is …

Total answers: 5

Logic behind Recursive functions in Python

Logic behind Recursive functions in Python Question: I have the following recursive function below that returns the k to the s power of a certain integer. However I do not understand how it works. The base class is 1 when s becomes 0. How is it so that the returned value is actually k^s when …

Total answers: 1

Python BeautifulSoup find_all() method return unnecessary element

Python BeautifulSoup find_all() method return unnecessary element Question: I’m having trouble with scrapping elements with the find_all() method. I am looking for the <li class=’list-row’>…..</li> tag but after scrapping it returns <li class=’list-row reach-list’> tags with different classes too. I tried with the select() method too. Here’s the python code: with open(‘index.html’, ‘r’) as f: …

Total answers: 1

Counting positive words in a passage python

Counting positive words in a passage python Question: I have to count the times positive and negative words appear in a passage. I have a list of positive words, list of negative words, and a passage excerpt. pos_words = [‘happy’, ‘like’, ‘love’, ‘good’, ‘favorite’, ‘best’, ‘great’, ‘amazing’, ‘joyful’, ‘positive’] neg_words = [‘sad’, ‘dislike’, ‘hate’, ‘angry’, …

Total answers: 3

Return several values inside for loop

Return several values inside for loop Question: I have a function that must return several values using a for loop. I do not wish to store the values inside a list or a dict. Because of the use of the return, I only get the first value. How can I return all values successively? I …

Total answers: 2

Python dash return several values inside for loop

Python dash return several values inside for loop Question: For my dash app, in order to update some graphs dynamically, I have to use a function that I named update_graphs inside a for loop. Some of the graphs contain several traces while some others only have one. The update_graphs function is called inside a callback …

Total answers: 1

Is using else faster than returning value right away?

Is using else faster than returning value right away? Question: Which of the following is faster? 1. def is_even(num: int): if num%2==0: return True else: return False def is_even(num: int): if num%2==0: return True return False I know you can technically do this: def is_even(num: int): return n%2==0 But for the sake of the question, …

Total answers: 1

how do I return a list containing print statements?

how do I return a list containing print statements? Question: So i am working on this function that takes a list as a parameter containing positive int, negative int, and the number 0 (zero). I have written the function using a while function with nested if statements to determine the value of each integer. Here …

Total answers: 3

Understanding the logic with conditions using return statement python

Understanding the logic with conditions using return statement python Question: I have the following exercise from codingbat.com: Given 2 int values, return True if one is negative and one is positive. Except if the parameter "negative" is True, then return True only if both are negative. So, when I was solving it, I’ve formulated a …

Total answers: 1

Call argument from multi returned arguments function using Python

Call argument from multi returned arguments function using Python Question: By using Python : I want to call just one argument from defined function (Angles) which return two arguments theta and phi. How can I call just theta value from Angles funcition and assign it to x value? values = [1,-1] g = np.random.choice(values) q= …

Total answers: 1