华为机考入门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 软件工程小施同学

相关推荐
hhy_smile9 分钟前
Python environment and installation
开发语言·python
莫非王土也非王臣1 小时前
网页端的TensorFlow开发实践
人工智能·python·tensorflow
喵手1 小时前
Python爬虫零基础入门【第七章:动态页面入门(Playwright)·第3节】优先 API:用 Network 找接口,回到 Requests(更稳定)!
爬虫·python·playwright·python爬虫实战·python爬虫工程化实战·python爬虫零基础入门·优先 api
zilikew1 小时前
Flutter框架跨平台鸿蒙开发——拼图游戏的开发流程
flutter·华为·harmonyos·鸿蒙
我送炭你添花1 小时前
Pelco KBD300A 模拟器:12.设备仿真与虚拟响应生成
python·自动化·运维开发
一晌小贪欢1 小时前
深入解析 Python 3.11 版本迭代:性能飞跃与更优雅的错误处理
python·python基础·python3·python3.11·python小白
理智.6292 小时前
根据requirements.txt 完成环境中的依赖库导入
python·conda·pip
Blossom.1182 小时前
用纯 NLP 打造「零样本」时序预测模型:文本化序列 + LLM 的实战路线
人工智能·python·深度学习·机器学习·自然语言处理·架构·transformer
小二·2 小时前
Python Web 开发进阶实战:AI 编排引擎 —— 在 Flask + Vue 中构建低代码机器学习工作流平台
前端·人工智能·python
sww_10262 小时前
智能问数系统(二):数据分析师Python
java·前端·python