Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python please help me with this code

ak.hxssxn

Coder
[UWSL][UWSL]Ask the user for two numbers.[/UWSL][/UWSL]
[UWSL][UWSL]Calculate the difference between the numbers. [/UWSL][/UWSL]
[UWSL][/UWSL]
[UWSL][UWSL]If it's 13 (-13 also counts), print "The difference between the two numbers is 13, YAYYAYAYAY"[/UWSL][/UWSL]
[UWSL][UWSL]Otherwise, print "Awwwwww, 13 is my favourite number D:"[/UWSL][/UWSL]
 
Hey there, @ak.hxssxn.

I'm just wondering if you've actually attempted to do anything so far. I have given you a solution to one question, @Ghost has given you a solution to another. But have you actually attempted to do anything yourself? Because if you don't, you won't make it very far in Computer-Science.

Respond when you can, because I'm curious to know if you have.
 
Hey there, @ak.hxssxn.

I'm just wondering if you've actually attempted to do anything so far. I have given you a solution to one question, @Ghost has given you a solution to another. But have you actually attempted to do anything yourself? Because if you don't, you won't make it very far in Computer-Science.

Respond when you can, because I'm curious to know if you have.
i have. i go to a coding school and do many codes. any codes i dont understand, i ask them here.
 
i tried but i didnt understand it
I'm not sure how you didn't understand it as it is one of the most basic programs you can create as a beginner. You're simply comparing the difference between two numbers and if either of those two numbers are 13, you print something. If they aren't 13, then you print something else. It really isn't that hard.

Anyway, I've managed to write a simple script that should hopefully do what you like(Somewhat anyway). It doesn't completely work as intended, probably due to an issue with the if-else if-statement. You may have to do some modifications of your own to get it working as intended. Either way, it does. The way it works currently is that if the first number is thirteen, then it prints that 13 is it's favourite number. If the second number is 13, then it prints that it's sad about 13 not being inserted for some reason. I tried different keywords like or instead of and, but that never seemed to work.

Here's the code anyway:
Python:
# Comparing the difference between two numbers.                                                                         
                                                                                                                        
Num1 = input("Insert the first number: ")                                                                               
Num2 = input("Insert the second number: ")                                                                              
                                                                                                                        
# Treat both Num1 and Num2 as integer values.                                                                           
Num1 = int(Num1)                                                                                                        
Num2 = int(Num2)                                                                                                        
                                                                                                                        
# Print the numbers the user has just inserted, simply to show them.                                                    
print("Your numbers: " + str(Num1) + " " + str(Num2))                                                                   
                                                                                                                        
                                                                                                                        
# Compare the difference                                                                                                
if Num1 and Num2 >= 13:                                                                                                 
     print("Aw. 13 is my favourite number.")                                                                            
elif Num1 and Num2 <= 13:                                                                                               
     print("Yay. 13!")
 
Back
Top Bottom