1.使用 python 表示数学式: ![](https://img-blog.csdnimg.cn/cc4dfef6bdac45d28e1773fd565514cb.png)
z="(5+10*x)/5 - 13*(y-1)(a+b)/x + 9(5/x+(12+x)/y)"
print(z)
print(z)
2. 从控制台输入用户的月薪,进行运算计算出年薪。打印输出用户的年薪
salary = input("请输入您的月薪:")
annual_salary= int(salary) * 12
print("您的年薪为:",annual_salary)
3. 使用字符串复制,用计算机打印出“爱你一百遍”,打印 100 次
#定义字符串
s = "爱你一百遍"
s = s * 100
print(s)
4. 将”to be or not to be”字符串倒序输出 ;
将”sxtsxtsxtsxtsxt”字符串中所有的 s 输出。
#对字符串进行切片操作
#题目:将“to be or not to be ”字符串倒序输出
#定义字符串
s="to be or not to be"
s=s[::-1]
print(s)
w="sxt"*5
print(w)
w=w[0::3]
print(w)
5. 判断如下输出结果,并文字解释原因:
a = "abcd_33"
b = "abcd_33"
c = "dd#"
d = "dd#"
print(a is b) #判断两个对象是否为同一个对象,比较的是地址
print(c is d)
print(a == b) #判断两个字符串是否含有相同的字符
6. 写出如下代码打印的结果:
c = "名字是{name}, 年龄是{age}"
c.format(age = 19, name = "高淇")