华为机考入门python3--(0)模拟题2-vowel元音字母翻译

分类:字符串

知识点:

  1. 字符串转list,每个字符成为list中的一个元素 list(string)

  2. 字符串变大小写 str.upper(), str.lower()

题目来自【华为招聘模拟考试】

python 复制代码
# If you need to import additional packages or classes, please import here.

def func():

    # please define the python3 input here. For example: a,b = map(int, input().strip().split())
    sentence = input().strip()
    my_list = list(sentence)
    # ['w', 'h', 'o', ' ', 'l', 'o', 'v', 'e']
    # print(my_list)
    
    vowels = ('a','e','i','o','u','A','E','I','O','U')
    new_my_list = []
    for letter in my_list:
        if letter in vowels:
            new_my_list.append(letter.upper())
        elif letter == ' ':
            new_my_list.append(letter)
        else:
            new_my_list.append(letter.lower())
    
    # print(new_my_list)
    new_sentence = ''.join(new_my_list)
    print(new_sentence)
    # please finish the function body here.
    # please define the python3 output here. For example: print().

if __name__ == "__main__":
    func()

by 软件工程小施同学

相关推荐
databook8 分钟前
从手动检查到自动监控:一个数据质量工作流的实现
后端·python·数据分析
北冥有鱼被烹2 小时前
砷化镓与磷化铟:光模块的地基——从化学键到AI缺货潮的底层逻辑
人工智能·python
for_ever_love__3 小时前
线性回归与梯度下降——从零手写一个模型
python·机器学习·线性回归·梯度下降
code_whiter4 小时前
7.自动化测试常用函数
python·功能测试
小园子的小菜4 小时前
Python协程深度解析:从原理演进到实战避坑
后端·python
砚底藏山河4 小时前
量化实战:截面因子有效性检验(IC 分析与分层回测)
java·python·金融·maven
GitFun5 小时前
给策略加了条-8%止损线,11年只触发1次
python·股票·量化交易
马六六i5 小时前
市面上正规的IP驱动产业新场景新工具有哪些
大数据·网络·python·tcp/ip
I Am a robert girl6 小时前
稀有事件估计的迭代去对齐:从源码视角拆解重要性采样新范式
开发语言·python·机器学习·重要性采样·蒙特卡洛方法·稀有事件估计
天若有情6736 小时前
开源|Comfort Lang v1.0.1,一款主打清爽交互的新型命令式编程语言
python·开源·交互·编程语言·项目分享·repl·comfort lang