The function given below is written to accept a string s as a parameter and return the number of vowels appearing in the string. The code has certain errors. Observe the code carefully and rewrite it after removing all the logical and syntax errors. Underline all the corrections made.
def CountVowels(s):
c=0
for ch in range(s):
if 'aeiouAEIOU' in ch:
c=+1
return(ch)for ch in range(s). The function range() needs an integer, but s is a string. Running range('abc') gives a TypeError. The loop must go over the string itself: for ch in s. if 'aeiouAEIOU' in ch. This asks if the whole vowel string is inside the single character ch, which is almost always False. We must ask if ch is inside the vowel string: if ch in 'aeiouAEIOU'. c=+1. This only sets c to +1 each time, so the count never grows. The correct form is c+=1. return(ch). This returns the last character, not the count. It must be return(c). def CountVowels(s):
c=0
for ch in s:
if ch in 'aeiouAEIOU':
c+=1
return(c)
def CountVowels(s):
c=0
for ch in s:
if ch in 'aeiouAEIOU':
c+=1
return(c)The SELECT statement when combined with \(\_\_\_\_\_\_\) clause, returns records without repetition.
print(16 * 5 / 4 * 2 / 5 - 8)
myStr[:4] extracts the first 4 characters, which are "MISS".myStr[-5:] extracts the last 5 characters, which are "SIPPI"."#" in between, resulting in "MISS#SIPPI".In SQL, the aggregate function which will display the cardinality of the table is \(\_\_\_\_\_\).
What will be the output of the following code?
def f1(a,b=1):
print(a+b,end='-')
c=f1(1,2)
print(c,sep='*')What is the difference between default parameters and positional parameters in Python? Also give an example of a function header which uses both.
What possible output(s) from the given options will NOT be displayed when the following code is executed? Also, mention, for how many iterations the for loop in the given code will run?
import random
a = [1,2,3,4,5,6]
for i in range(4):
j = random.randrange(i,5)
print(a[j],end='-')
print()Write the output of the following code:
def Exam2026(given) :
new=[]
for ch in given[1:-1]:
if ch.isupper():
new.reverse()
elif ch not in new:
new.append(ch)
elif ch in new:
new.pop()
print(new)
Exam2026("Gold-24Medals")Write the output of the following code:
def Exam2026(given):
new = 0
while given:
if new % 2:
new += given % 10
else:
new += given % 5
print(new, end='-')
given //= 10
Exam2026(123456)