cars=['audi','bmw','subaru','yoyota']
for car in cars:
    if car=='bmw':
        print(car.upper())
    else:
        print(car.title()) #5.1一个简单示例
print(car)

mushroom='mush'
if mushroom!='mush':
    print(False)
else:
    print(True) #5.2条件测试，更多在后台做的测试无法出现在这里，我截图放在obisidian上面了

#exercise1
#
ages=[-1,6,13,19,1.1]
for age in ages:
    if age<=12:
        print('Have a nice school day.\n')
    elif age >=18:
        print('You are old enough to vote.')
        print('Have you registered to vote yet?\n')
    else:
        print('Sorry,you are too young to vote.')
        print('Please register to vote as soon as you ture 18\n')
for age in ages:
    if age<=4:
        price=0
        print(f'your adimission cost is {price}')
    elif age<=12:
        price=10
        print(f'your adimission cost is {price}')
    elif age<=18:
        price=20
        print(f'your adimission cost is {price}')
    else:
        price=40
        print(f'your adimission cost is {price}')
for age in ages:
    if age<=4:
        price=0
        print(f'your adimission cost is {price}')
    elif age<=12:
        price=10
        print(f'your adimission cost is {price}')
    elif age<=18:
        price=20
        print(f'your adimission cost is {price}')
    elif age>18:                                 #使用elif而非else，可以使代码块更清晰，防止引入无效或恶意的数据
        price=40
        print(f'your adimission cost is {price}')
requested_troppings=['mushrooms','extra cheese','pepperroni']
if 'mushrooms' in requested_troppings:
    print('\nAdding mushrooms\n')                #试图在引号外加\n,导致了标红，看来\n算文本信息
if 'extra cheese' in requested_troppings:
    print('Adding extra cheese\n')
if 'pepperroni' in requested_troppings:
    print('Adding peeperoni\n')                  #5.3if语句
print('\n Finished making your pizza!\n\n')          #测试多个条件，与if-elif-else语句效果不同，不过其实if-elif-else语句联合foe语句也可以达到类似效果

#exercise5.3
monster_colors=['red','yellow','green','red']       #situation1
for color in monster_colors:
    if color == 'red':
        print("you have win 5 points")
    if color == "yellow":
        print("you have win 10 points")
    if color == "green":
        print("you have win 10 points")
monster_colors=['red','yellow','green','red']       #situation2#有二者的区别可以看出，第二种代码方式无法用于相同选项的重复统计，
if 'red' in monster_colors:                         #这是因为下文中没有for循环来遍历列表中的内容
    print(5)
if 'green' in monster_colors:
    print(10)
if 'yellow' in monster_colors:
    print(15)
monster_colors=['red','yellow','green','red']      #situation3
for color in monster_colors:                       #此处与situation1的最终结果并没有因为if 改成了elif就发生变化，不过内部的运算逻辑是变化了的
    if color == 'red':
        print("you have win 5 points")
    elif color == "yellow":
        print("you have win 10 points")
    elif color == "green":
        print("you have win 10 points")
#there are more exercises,but they are all the same,so i'm nit gonna weast time on it

words=['A','B','C','D','E','F']
for word in words:
    if word=='A':
        print("the word is not available")
    else:
        print(f'Adding {word}.')
print('\nFinished.')                #5.4.1检查特殊元素
words=[]
if words:                               #当在if语句中以列表名做条件表达式时，python在至少有一个元素时返回True，在列表为空时返回False
    print('the list is not empty')
else:
    print('the list is empty')      #5.4.2测试列表是不是空的
available_words=['A','B','C','D']
words=['A','B','C','D','E','F']
for word in words:
    if word in available_words:
        print(f"the wordtest {word.lower()} isn't finshed")
    else:
        print(f"the wordtest {word.lower()} is finshed")       #5.4.3使用多个列表 #5.4

#exercise5.4
user_names=['A','BEN','Cat','david','Admin']
for user_name in user_names:
    if user_name == 'Admin':
        print(f"hello,{user_name},would you like to see a status report")
    else:
        print(f"hello,{user_name},thanks for logging in again")   #5-8
user_names=[]          
if user_name:
    for user_name in user_names:
        if user_name == 'Admin':
            print(f"hello,{user_name},would you like to see a status report")
        else:
            print(f"hello,{user_name},thanks for logging in again")  
    else:
        print('We need some users')                            #5-9
currunr_user_names=['A','BEN','Cat','david','Admin']
new_user_names=['A','BEN','cat','da','dog']
for new_name in new_user_names:
    if new_name in currunr_user_names:
        print(f'{new_name},there already a name exsit,try a new name.')
    else:
        print(f"{new_name},the name wasn't used before")        #5-10 这里有个问题，我不知道怎么将列表中的元素转换成upper形势统一比较
currunr_user_names = ['A', 'BEN', 'Cat', 'david', 'Admin']      #以下为改进方法 在想要大范围改变列表内容的时候活用列表解析
new_user_names= ['A', 'BEN', 'cat', 'da', 'dog']
current_users_upper = [currunr_user.upper() for currunr_user in currunr_user_names]
for new_name  in new_user_names:
    if new_name.upper() in current_users_upper:
        print(f'{new_name}, there already a name exsit,try a new name.')
    else:
        print(f"{new_name}, the name wasn't used before")
numbers=[1,2,3,4,5,6,7,8,9,]
for number in numbers:
    if number==1:
        print(f"{number}st")
    if number==2:
        print(f"{number}nd")
    if number==3:
        print(f"{number}rd")
    else:
       print(f"{number}th")            #5-11
#exercise finished

#5.5设置if语句的格式
#建议在运算符号前后各添一个空格以保持美观

#ddepseek补充
#你的代码里多处用了 is 来比较字符串，
#== 用来比较值是否相等（这是你最应该在条件测试里用的）。

#is 用来比较是不是同一个内存地址，虽然偶尔碰巧能用在短字符串上，但在编程里是极不规范的写法，容易踩坑。

#建议：把你所有代码里的 is 都换成 ==：
#已改





