Skip to content

liuqiyucn/COGS-18-FINAL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Author: Qiyu Liu\n",
    "PID: A15655200\n",
    "\n",
    "# Introduction:\n",
    "\n",
    "This is an user interactive program that utilize can calculate a complex expression. User can enter a valid mathematical expression such as \"4! + 5\", and the program will evaluate to 29. User can simply follow the instructions given. It is very self-explanatory.\n",
    "\n",
    "## Files:\n",
    "\n",
    "* `Calc.py`:\n",
    "\n",
    "This file contains all the necessary methods that consist of a calculator class. The main two part are the evaluate and intopost function. These functions were written by me in c when taking CSE 12. However, I have modified these functions in order for them to work in python. For instance, python does not have bit manipulation, so I authored precedence function to get the priority of the operator. The function that read an integer from a string is also not provided. Therefore, I wrote a decin function and is_digit function to accomplish the task. I also author the remove_str function to remove processed substring from the expression string. There's no given stack, so I utilize list as a stack in this case. All the methods that were previously written is indicated in the docstring. Original methods for this assignment is also indicated.\n",
    "\n",
    "* `Driver.py`:\n",
    "\n",
    "This file contains the main user interative interface for a calculator. It will prompt user for user input and evaluate the expression. It also has the functionality of detecting non-valid characters input by the user. All of the functions in this file are written by me specifically for this assignment. The prompt method will prompt the user for the epression to evaluate. The main function will keep the program running until the user enter something other than y when asked. \n",
    "\n",
    "* `Test.py`:\n",
    "\n",
    "This file contains the test cases for decin and isvalid_exp. Decin should read a number substring from a string, while isvalid_exp will check if a string contains invalid character for expression.\n",
    "\n",
    "## Extra Credit:\n",
    "\n",
    "I have explored many things that are not taught in the class. First of all, I have implemented this calculator with a stack data structure using a list. In addition, I have explored the use of recursion to calculate factorial and exponential expression throughout my assignment. In addition, I have realized many of the difference between C and Python through this final project. I have to replace many usage of pointer with something else in Python. Bit manipulations are also replaced by my own original functions.\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import Driver"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Driver.main()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages