Skip to main content
Removed extraneous commentary on not liking C++
Source Link
Chris
  • 6.1k
  • 1
  • 7
  • 41

I've been a C++ student at Uni for half a year. I'm not too interested in C++ though - it makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

This program takes a user input to choose which calculation method they'd like to use, then uses a separate module and the math library to perform said calculation.

I've been a C++ student at Uni for half a year. I'm not too interested in C++ though - it makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

This program takes a user input to choose which calculation method they'd like to use, then uses a separate module and the math library to perform said calculation.

This program takes a user input to choose which calculation method they'd like to use, then uses a separate module and the math library to perform said calculation.

added 16 characters in body; edited tags
Source Link
toolic
  • 16.4k
  • 6
  • 29
  • 221

I've been a C++ student at Uni for half a year, I'm. I'm not too interested in C++ though - it makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

I'd like some feedback as to how this looks as a Python program, have. Have I broken any major rules? Been I've been learning Python for maybe two weeks now,now; the last time I used it was at highschoolhigh school in 2017.

I've been a C++ student at Uni for half a year, I'm not too interested in C++ though - makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

I'd like some feedback as to how this looks as a Python program, have I broken any major rules? Been learning Python for maybe two weeks now, last time I used it was at highschool in 2017.

I've been a C++ student at Uni for half a year. I'm not too interested in C++ though - it makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

I'd like some feedback as to how this looks as a Python program. Have I broken any major rules? I've been learning Python for maybe two weeks now; the last time I used it was at high school in 2017.

Became Hot Network Question
Source Link

Python implementation of core fundamentals to calculate math arithmetic

I've been a C++ student at Uni for half a year, I'm not too interested in C++ though - makes me feel like I'm beating my head against a wall, so I've been teaching myself Python instead.

This program takes a user input to choose which calculation method they'd like to use, then uses a separate module and the math library to perform said calculation.

I'd like some feedback as to how this looks as a Python program, have I broken any major rules? Been learning Python for maybe two weeks now, last time I used it was at highschool in 2017.

main.py

import math
from modules import arithmetic 

programRunning = True

# Exploration of Python's fundamentals.

# Match Case selection for calculation selection:
while(programRunning):
    print("\nPlease select the calculation that you wish to perform:")
    print("\n-------------------------------------------------------")
    print("0 -- Square root")
    print("1 -- Exponents")
    print("2 -- Cube Root")
    print("-------------------------------------------------------")
    calculationSelection = int(input("\nPlease select the calculation that you wish to perform:"))

    match calculationSelection:
        case 0:
            arithmetic.selectSquareRoot()
        case 1:
            arithmetic.selectExponent()
        case 2:
            arithmetic.selectCubeRoot()
        case _:
            print("\nERROR: Invalid Selection\n")

arithmetic.py

import math

def selectSquareRoot(): # Square Root 
    squaredNum = int(input("\nPlease enter the square number to be rooted: "))
    squareRootNum = math.sqrt(squaredNum)
    print(f"\nThe square root of {squaredNum} is {squareRootNum}.")

def selectExponent(): # Exponents
    exponentialNum = int(input("\nPlease enter the number to be raised: "))
    powerNum = int(input("\nPlease enter the power to raise the number to: "))
    raisedExponent = math.pow(exponentialNum, powerNum)
    print(f"\n{exponentialNum} to the power of {powerNum} is {raisedExponent}.")

def selectCubeRoot(): # Cube Root
    cubedNum = int(input("\nPlease enter the cubed number to be rooted: "))
    cubeRootNum = math.cbrt(cubedNum)
    print(f"\nThe cube root of {cubedNum} is {cubeRootNum}.")