#🔒 Help with python homework and some yt tutorials to help me learn
32 messages · Page 1 of 1 (latest)
@midnight siren
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.
@midnight siren ok, that seems straight forward. I assume there's some preexisting programme you're supposed to modify?
Yes
Py print("Welcome to Adventure Beta")
name = input("Enter the name of adventurer 1: ")
character_class = input("Enter the class of adventurer 1: ")
player_level = int(input("Enter the level: "))
health = player_level + 6
description = name + "the" + character_class
print(f"{description} is level {player_level} with {health} health points.")
Was the original code
Could you edit that to put a line with ```py above the code and a line with ``` below it. Makes it fixed width and more importantly, some programme code will be renders as font stuff (eg italics) without this.
So, doing the assignment means doing each individual task. One at a time ideally.
Not sure what to change I’ll try tho
Start with the first one.
I'd be adding an if statement riht under the name = line.
Just have a guess, and we can fix it up.
I don’t even know where to start
Ok. You've got this:
print("Welcome to Adventure Beta")
name = input("Enter the name of adventurer 1: ")
character_class = input("Enter the class of adventurer 1: ")
player_level = int(input("Enter the level: "))
health = player_level + 6
description = name + "the" + character_class
print(f"{description} is level {player_level} with {health} health points.")
So the character name is saved in the variable name.
You know that value right after the name = line. (Have they explained the input() function and so on? Did you write all of the above?)
So we want to see if that was eg "Gandalf".
if name == "Gandalf":
print("it's Gandalf!")
No the tutor literally just gave me the answers
Oh. That's not much good. Let' s dissect it then.
The print() functions writes text to your terminal. It writes each of its arguments (values) with a space between, and a newline at the end.
So print("a", 3) prints:
a 3
The input() function issues a prompt, then reads a line of text from the terminal (i.e. you, the user). It returns a string holding that text.
This line:
name = input("Enter the name of adventurer 1: ")
calls input(), which issues the prompt Enter the name of adventurer 1: , reads some text (the name) and returns that.
This returned value is saved in the variable name. For use later.
So name contains a string, a piece of text.
This one's a bit different:
player_level = int(input("Enter the level: "))
This also calls input() and gets the player level. It's still a string, not a number.
The value from input() is then passed to the int() function, which converts it to an int, Python's integer type.
The result of that call is saved in the variable player_level. It is an int, a whole number.
Is this making sense? Am I belaboring stuff you already know?
honestly its not that hard for some reason although im just starting
Hmm, this isn't Unknownlrgirl
ok
That's fine.
You're not rejected, I'm just help the OP though.
Trying to gauge what knowledge they have, what help they may need.
This help channel has been closed. 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.