Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
How do I classify valuable variables without using built-in functions in Python 3.10?

I am currently trying to sort the values ​​entered by the user and print them from low to high then high to low minimizing the use of built in functions. I think my code is on the right track, however in my terminal when my code tries to present my entered values ​​it will display the first entered value twice in the output and then skip the last entered value in the output.

Entering this on this website, I'm starting to think that maybe my problem is that I didn't need to create the 'number1tem', 'number2tem' and 'number3tem' variables. But instead enter some kind of 'and' function like:

 if number1 <= highest and is => lowest: number1 == middle elif number2 <= highest and is => lowest: number2 == middle elif number3 <= highest and is => lowest: number3 == middle

However, I'm not sure how to format the 'and is' statement. Or if this would actually work.

This is my complete code:

 number1 = input("Give me a number between 1 and 100:") if number1 in range (0 - 100): print ("your number is accepted") number2= input("Give me another number between 1 and 100:") if number2 in range (0 - 100): print("your number is accepted") number3= input("Give me another number between 1 and 100:") if number3 in range (0 - 100): print ("your number is accepted") if number1 <= number2 and number3: lowest = number1 elif number2 <= number1 and number3: lowest = number2 elif number3 <= number1 and number2: lowest = number3 if number1 >= number2 and number3: highest = number1 elif number2 >= number1 and number3: highest = number2 elif number3 >= number1 and number2: highest = number3 if number1 <= highest: number1tem = number1 elif number2 <= highest: number2tem = number2 elif number3 <= highest: number3tem = number3 if number1tem >= lowest: middle = number1tem elif number2tem >= lowest: middle = number2tem elif number3tem >= lowest: middle = number3tem print('Ascending order is:', lowest, middle, highest) print('Descending order is:' highest, midddle, lowest)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You probably need something like this:

 #setup num1 = 98 #you can get this with input() num2 = 5 #you can get this with input() num3 = 52 #you can get this with input() nums = [num1, num2, num3] maximum = num1 minimum = num1 #this gets the max and min for n in nums: if n < minimum: minimum = n if n > maximum: maximum = n for n in nums: if n != maximum and n != minimum: middle = n print("increasing: ", minimum, middle, maximum) print("decreasing: ", maximum, middle, minimum)

Production:

 increasing: 5 52 98 decreasing: 98 52 5
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!