Three Integer marks, their Integer total, and a Real average.
Integer into RealDatatypes
Built from 3 kinds of block, between Start and End. Each one has a guide.
B4Coder writes the same program as real code. Change the flowchart in the editor and the code changes with it.
import math
def round_half_up(x, digits=0): # Like round() in B4Coder: a half goes up, so 2.5 is 3 (Python's round() gives 2). scale = 10 ** digits whole = math.floor(x * scale) if x * scale - whole >= 0.5: whole += 1 return whole if digits == 0 else whole / scale
m1 = int(input("Marks in subject 1 "))m2 = int(input("Marks in subject 2 "))m3 = int(input("Marks in subject 3 "))total = m1 + m2 + m3average = round_half_up(total / 3, 2)print("Total: " + str(total))print("Average: " + str(average))How each block becomes code: Python · Java · C++ · C# · JavaScript