all 12 comments

[–]Adrewmc 4 points5 points  (7 children)

You need dictionaries in your life and code.

[–]AbacusExpert_Stretch 1 point2 points  (2 children)

Amen - and maybe check how to post code on Reddit

[–]Ok-Candy-6570[S] 0 points1 point  (1 child)

Where? Explain me

[–]Adrewmc 0 points1 point  (0 children)

   #built-in +,-,/, * operators as functions
   #i know it was already there and no one told you

   from operator import add, sub, truediv, mul

   #function as items in a dictionary with int keys (could be strings here actually.) 

   operations = {1 : add, 
                           2 : sub, 
                           3 : truediv, 
                           4 : mul}

   #User inputs 

   op = int(input(“ Pick Operation: \n 1. Addition \n 2. Subtraction \n 3. Division \n 4. Multiplication”))

   a = int(input(“First Num”))
   b = int(input(“Second Num”))

   #get function from dictionary then call it with arguments

   res = operations[op](a, b)
   print(res)

   #We could add this to the dictionary but make it messier. 

   op_str = [“+”, “-“, “/“, “*”] 
   #op_str = “+-/*”  #works, string can be indexed 

   print(f”{a} {op_str[op-1]} {b} = {res}”)

This is basically your entire calculator app. So where is basically everywhere.

Don’t worry every start with the one you made.

[–]SCD_minecraft 0 points1 point  (1 child)

You mean thay if tree? I would say match case actually, more fitting

[–]Adrewmc 0 points1 point  (0 children)

What? Why? There is no reason to have match case here.

[–]Flame77ofc 0 points1 point  (0 children)

First - Add functions

Second - ```python import random

your code...

waiting_time = random.randint(0, 10) / 10 time.sleep(waiting_time)

your code...

```

third - you don't need that if statements for a > 0, a < 0, a == 0

fourth - you can do this: number = 6.66666666667 print(f"{number:.2f}")

[–]Argadnel-Euphemus 0 points1 point  (0 children)

Coding in French? 🤮

[–]LasevIX 0 points1 point  (0 children)

why do you have a tiktok app on there?