Solution of Worksheet Basic String
Solution of Worksheet Basic String
BASIC
Ans:
total=0
for i in range(1,6):
marks = float(input("Enter marks for subject " + str(i) + ": "))
total= total+marks
avg=total/5
print("Avergre marks is " ,avg)
if temp==sum:
print(num,"is an armstrong number")
else:
print(num,"is not an armstrong number")
(String)
8. Write a program to count the number of vowels in the
string.
Ans:
str="We are learning python"
v=0
for i in str:
if i in "AEIOUaeiou":
v=v+1
print("No. of vowels in given string",v)
or
or
Ans:
input_string = input("Enter a string: ")
# Replace all occurrences of the first character (except the first one)
with 'S'
modified_string = first_char + input_string[1:].replace(first_char, 'S')