|
| 1 | +def test(): |
| 2 | + x=9+4 |
| 3 | + print("if answer is true it is ",x==13) |
| 4 | + print("check whether it is true : its",3+3<2+4) |
| 5 | +test() |
| 6 | + |
| 7 | +def test2(x,y): |
| 8 | + if(y>=x+x): |
| 9 | + print(y, "greater than or equal", x + x ,"is true.") |
| 10 | + else: |
| 11 | + x = 3 |
| 12 | + y = x + 8 |
| 13 | + |
| 14 | +x=input("Enter x:") |
| 15 | +y=input("Enter y:") |
| 16 | +test2(x,y) |
| 17 | +if("Hello">"hello"): |
| 18 | + print("True") |
| 19 | +else: |
| 20 | + print("False") |
| 21 | +name = "Tobias" |
| 22 | + |
| 23 | +print(name == "Alton") |
| 24 | +#check casting |
| 25 | +str_integer='700' |
| 26 | +int_number=200 |
| 27 | +number_total=int_number+int(str_integer) |
| 28 | +print(number_total) |
| 29 | +a=int(input("enter digits:")) |
| 30 | +b=int(input("enter digits:")) |
| 31 | +output=a+b |
| 32 | +print(a,"+",b,"=",output) |
| 33 | + |
| 34 | +size_num = "8 9 10" |
| 35 | + |
| 36 | +size = "8" # user input |
| 37 | + |
| 38 | +if size.isdigit() == False: |
| 39 | + print("Invalid: size should only use digits") |
| 40 | +elif int(size) < 8: |
| 41 | + print("size is too low") |
| 42 | +elif size in size_num: |
| 43 | + print("size is recorded") |
| 44 | +else: |
| 45 | + print("size is too high") |
| 46 | + |
| 47 | + |
| 48 | +num="20" |
| 49 | +if(num.isdigit()): |
| 50 | + print("ok",num.isdigit()) |
| 51 | +else: |
| 52 | + print("NO",num.isdigit()) |
| 53 | +operator=input("Select operator(*,/):") |
| 54 | +a=int(input("enter digits:")) |
| 55 | +b=int(input("enter digits:")) |
| 56 | +def multiply(a,b,ope): |
| 57 | + if(ope=="/"): |
| 58 | + c=a/b |
| 59 | + equa=str(a)+"/"+str(b)+"="+str(c) |
| 60 | + return equa |
| 61 | + elif(ope=="*"): |
| 62 | + c=a*b |
| 63 | + equa=str(a)+"*"+str(b)+"="+str(c) |
| 64 | + return equa |
| 65 | + else: |
| 66 | + print("Invalid operator") |
| 67 | +print(multiply(a,b,operator)) |
| 68 | +calculation = 5 + 3 + 3 * 2 - 1 |
| 69 | +print(calculation) |
| 70 | + |
| 71 | +maximum=100 |
| 72 | +minimum=50 |
| 73 | +price=144 |
| 74 | +value=float(input("Enter cheese order weight (numeric value):")) |
| 75 | +def cheese_order(val,max,min,p): |
| 76 | + if val>max: |
| 77 | + print(val,"is more than currently available stock.") |
| 78 | + elif val<min: |
| 79 | + print(val,"is below minimum order amount.") |
| 80 | + else: |
| 81 | + print(val,"costs","$"+str(p),".") |
| 82 | +cheese_order(value,maximum,minimum,price) |
| 83 | + |
0 commit comments