#๐Ÿ”’ I need help for my AP exam

42 messages ยท Page 1 of 1 (latest)

acoustic needle
#

I just wanted to know if this calculator technically has an algorithm

import sys

#Start of defined varibles

options = {1, 2, 3, 4}

def addition (x, y):
    print ("Your answer is", x+y,"!")

def substraction (x, y):
    print ("Your answer is", x-y,"!")

def multiplication (x, y):
    print ("Your answer is", x*y,"!")

def division (x, y):
    if y == 0:
        print ("You cannot divide by 0. Please try again")
        exit()
    else:
        print ("Your answer is", x/y,"!")

#End of defined variables

print ("Hello, welocome to your personal calculator")

operation = (int(input("What operation would you like to do today? \n \n 1. Addition \n 2. Substraction \n 3. Multiplication \n 4. Division \n")))

if operation in options:
    x = int(input("What is the first number you would like to use\n"))

    y = int(input("What is the second number you would like to use\n"))

    if operation == 1:
        addition(x, y)
    if operation == 2:
        substraction(x, y)
    if operation == 3:
        multiplication(x, y)
    if operation == 4:
        division(x, y)
    
else:
    print ("Your option is not available please try again")
    exit()```
obsidian geodeBOT
#

@acoustic needle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

acoustic needle
#

Alr bet thank you

#

would you happen to know what type of algorithm it has?

eager fern
#

There's a type?

acoustic needle
#

there isn't types of algorithms?

eager fern
#

oh those kinds

#

What do you think?

acoustic needle
#

"An algorithm that includes sequencing, selection, and iteration that is in the body of the selected procedure"

acoustic needle
#

I have no clue

eager fern
acoustic needle
acoustic needle
eager fern
#

Odd. How are you taught about the types of algos? Have you a text book or something for reference?

eager fern
acoustic needle
#

I'm going to be 100% honest with you, it's not my AP exam, it's my friends and he didn't pay attention, I took a boot camp and have been somewhat keeping up on my python, I just write I don't really know key concepts like that

acoustic needle
#

cuz if it satisfies that I may or may not have just BSd my way through an AP exam that's not even mine

eager fern
#

lol

#

you dug yourself a hole here haha

acoustic needle
#

Why do you say that ๐Ÿ‘๏ธ๐Ÿ‘๏ธ

eager fern
#

Well, if I were you, I'd just google my way through

acoustic needle
#

It's what I've been doing

#

that's how I got this far ngl

eager fern
#

Types of algos are found online but not sure if that's covered in your friend's AP

acoustic needle
#

this is the last thing, if I can get a clear answer as of the fact that it satisfies that parameter I'm done

acoustic needle
#

Step 1: Start
Step 2: Get the knowledge of input. Here we need 3 variables; a and b will be the user input and c will hold the result.  
Step 3: Declare a, b, c variables.
Step 4: Take input for a and b variable from the user.
Step 5: Know the problem and find the solution using operators, data structures and logic

We need to multiply a and b variables so we use * operator and assign the result to c. 
That is c <- a * b

Step 6: Check how to give output, Here we need to print the output. So write print c
Step 7: End```
#

so it's basically that

#

but I didn't assign the result to a variable

#

so is it still an algo?

#

wait

#

I think I can modify it slightly to assign it

eager fern
#

Its still an algo

abstract wagon
acoustic needle
#

alr so I just found out it doesn't satisfy iteration but I can fix that real quick by looping it and just adding an exit feature at the start

obsidian geodeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.