python 输入三个用户提供的语句并解答问题的代码

htzpubme  于 2022-12-02  发布在  Python
关注(0)|答案(1)|浏览(66)

用于输入三个用户提供的语句的代码。标题大小写中是否有任何信息?对字母进行合计以确定其数目。对所有单词进行计数。以“e”开头的单词有多少个?以“er”结尾的单词有多少个?这些句子中每个句子的元音数。这些语句是否包含任何数字?反转第二个Assert。一次反转第三个语句中的一个单词。
请通过python解决

q3qa4bjr

q3qa4bjr1#

a = input("First statement : ")
b = input("Second statement : ")
c = input("Third statement : ")
al = a.split()
bl = b.split()
cl = c.split()
counte = 0
counter = 0
letter = 0
bll = ""
vowels = 0
ans = 0
ansb = 0
ansc = 0
print(f"The words in first statement is {len(al)}")
print(f"The words in second statement is {len(bl)}")
print(f"The words in third statement is {len(cl)}")
print(f"Total words {len(al)+len(bl)+len(cl)}")
for i in al:
    g = len(i)
    letter += g
    for vow in range(0, len(i)):
        if i[vow] == 'a' or i[vow] == 'i' or i[vow] == 'e' or i[vow] == 'o' or i[vow] == 'u':
            vowels += 1

    if i[0] == 'e':
        counte += 1
    if i[g-1]+i[g-2] == "re":
        counter += 1

for j in bl:
    h = len(j)
    letter += h
    for vow in range(0, len(j)):
        if j[vow] == 'a' or j[vow] == 'i' or j[vow] == 'e' or j[vow] == 'o' or j[vow] == 'u':
            vowels += 1
    if j[0] == 'e':
        counte += 1
    if j[h-1]+j[h-2] == "re":
        counter += 1
for k in al:
    u = len(k)
    letter += u
    for vow in range(0, len(k)):
        if k[vow] == 'a' or k[vow] == 'i' or k[vow] == 'e' or k[vow] == 'o' or k[vow] == 'u':
            vowels += 1
    if k[0] == 'e':
        counte += 1
    if k[u-1]+k[u-2] == "re":
        counter += 1
print(f"The total letters is {letter}")
print(f"The words starting with e is {counte}")
print(f"The words ending with er is {counter}")

# Reversing the second statements
revb = b[::-1]
print(f"The second statement reversed : {revb}")
# Third statement reverse word by word
for words in bl:
    words = words[::-1]
    bll += words+" "
print(f"The third statement reversed word by word : {bll}")
print(f"The total number of vowels is {vowels}")
li = ['0', '1', '3', '2', '4', '5', '6', '7', '8', '9']
for gh in al:
    for ff in range(len(gh)):
        if gh[ff] in li:
            ans = 967
            print("Numbers are there in first statement ")
            break
for ghk in bl:
    for ffd in range(len(ghk)):
        if ghk[ffd] in li:
            ansb = 9673
            print("Numbers are there in second statement ")
            break
for ghks in cl:
    for fffd in range(len(ghks)):
        if ghks[fffd] in li:
            ansc = 96733
            print("Numbers are there in third statement ")
            break
if ans == 0:
    print(" No Numbers are there in first statement ")
if ansb == 0:
    print(" No Numbers are there in second statement ")
if ansc == 0:
    print(" No Numbers are there in third statement ")

#Code is Completed

相关问题