online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
''' Demo code for module 1 part 2 "Basic Math" 9/14/2021 -Dr. G Let's review the different mathmatical operators that are possible and how to use them within your code. Tip: when in doubt use IDLE ''' #Concept 1 #Basic math and the order of operations (concatanation and string multiplication) # + - * / % ** // ''' Think back to the order of operations. Python enfoces that with operators you are familar with and some you likely aren't. If you get unexpected results, check the order of operations or when in doubt use parentheses. In order: ** *,/,//,% +,- ==,!=,<=,>=,>,< not and or ''' ''' result = 4 + 2 * 3 print(result) #you can also just print the result #print(2**2) #what is this and how would it be useful? #print(2%2) #print(3%2) #what's the difference in / and // #print (4/3) #print (4//3) ''' ''' #Assignment operators are shortcuts for var = var "operator" "number" # = += -= *= /= %= //= **= var = 2 var +=1 #print(var) #var *= 2 #print(var) #var **= 2 #print(var) ''' ''' #String operators # + * var1 = "cat" var2 = " in the hat" var3 = var1 + var2 print(var3) #we can also use it to repeat #print(var3 * 2) ''' ''' #A more applicable example would be this: result = 4 + 2 * 3 print("4+2*3 = " + str(result)) print("*" * 10) #Why did I convert result to a string? ''' ''' result = 3**2 print("3**2 = " + str(result)) print("*" * 10) ''' #ICE 1 a right triangle ''' For a triangle with side 1 of size 4 and side 2 of size 3 calculate and print the hypotenuse using the Pythagorean theorem. Store each value in a variable and print the third variable that holds the result. ''' ''' #Concept 2 : Boolean expressions and logical operators flag_1 = True flag_2 = False print(flag_1) print(flag_2) ''' ''' #Why do I have to convert these to strings for them print, but not above? print(str(flag_1) + " " + str(flag_2)) print(int(flag_1)) print(int(flag_2)) ''' #Concept 3 : logical operators that return boolean values #< > <= >= == != ''' flag_1 = 1 > 2 print(flag_1) print(2==2) #predict the following #print(2 != 2) #print(True > False) #print((6 + 3 / 3) >= (4 - 5)) #print(5 = 9) #print(False == 0) #print("CAT" == "cat") #print("dog" == "dog") #print('a' < 'b') #print("dog" < "cat") #print("bob" == "bob ") #print(1 > 4 == False) #print(bool(15 > 150) == False) #print(bool(4 == 4) == "True") ''' #Always watch out for = vs == #Concept 4 Boolean operators #and or not ''' #and print(True and True) print(True and False) print(False and False) #or print(True or True) print(True or False) print(False or False) #not print(not True) print(not False) '''

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue