#๐ PYTHON FOR BEGINNERS
87 messages ยท Page 1 of 1 (latest)
@stable marsh
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.
i have no idea how to start all of those three
- tells you each step in order
- take input from user
- is even?
- print event
- is odd?
- print odd
can python automatically identify if an integer is odd/even?
Yes
oh
Use the % operator
to what
Okay so you input a number
whered u get those numbers
I mean assign a number to a variable
done
What's your variable
So n = int(input("Enter number "))
what does the n % 2 == 0 mean
Basically it means if n divided by 2 has 0 as a remainder
So add this to your code
And then use an else statement for if the number is odd
ive finished it
n = int(input("Enter a value: "))
if n % 2 ==0:
print("The value is even")
else:
print("The value is odd")
print("Thank You")```
thanm you!!
now for item 2
still dk how to starf
yeah i meant after that
ok what do you think needs to be done then?
i dont know..
idk what to tell python what to do in order for me to execute the given problem
i was thinking earlier to assign a list of values to a variable, like A = 90 to 100 but idk how to do that and im sure there's an easier way than making a list manually
ok i see. You could do that, but then it makes it so you basically have to type out every number from 0 to 100
you don't want that right
yes
do you know what and, or, and not do?
no
these are called boolean operators
however, there's a way to do this without needed them
you can do (psuedo code)
- if grade is >= 90
- A
- otherwise, if grade is >= 80
- B
- otherwise, if grade is >= 70
- C
etc.
can you make an example writing that in py?
no because then i'd just be giving you the answer
you'll want to use if and elif and else
Well what does the question say about that?
oh, u just used it as a word to not give the answer?
okay what
currently 1am im just trying my best to stay awake
nvm i think i know
okay i did it
now i just wanna know how to tell my code anything >100 is an invalid input
nvm
just done it too
Nice
n = float(input("Enter your grade: "))
if n > 100:
print("invalid")
elif n >= 90:
print("A")
elif n >= 80:
print("B")
elif n >= 70:
print("C")
elif n >= 60:
print("D")
else:
print("FAILED")```
you don't need me ๐
thank you!!
well, i wouldnt have finished it without your help so thank you so much!!!
no prob
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.