Join the QuestionCove community and study together with friends!
Sign Up
Gucchi:
@smokeybrown are you available?
Ultrilliam:
Alright, some tips, when asking for programming help, specify the language of which you need help with, no 2 languages are equal. Additionally, I notice from your past posts, you do not use code blocks, which you really should.
\```language here
code here
\```
^you can fill out a language, but by default you don't actually have to as it auto-detects the language by default. For example, for python you can put python, or simply py. Javascript or JS, ETC. Just some tips there.
Now then, as for what you need help with. What is you need help with?
Gucchi:
@ultrilliam wrote:
Alright, some tips, when asking for programming help, specify the language of which you need help with, no 2 languages are equal. Additionally, I notice from your past posts, you do not use code blocks, which you really should.
```language here
code here
```
^you can fill out a language, but by default you don't actually have to as it auto-detects the language by default. For example, for python you can put python, or simply py. Javascript or JS, ETC. Just some tips there.
Now then, as for what you need help with. What is you need help with?
what is a code block ?
Gucchi:
@ultrilliam wrote:
Alright, some tips, when asking for programming help, specify the language of which you need help with, no 2 languages are equal. Additionally, I notice from your past posts, you do not use code blocks, which you really should.
```language here
code here
```
^you can fill out a language, but by default you don't actually have to as it auto-detects the language by default. For example, for python you can put python, or simply py. Javascript or JS, ETC. Just some tips there.
Now then, as for what you need help with. What is you need help with?
i need help with python
mainly ASCII for this question
I mean, I just told you what a code block was. It parses and highlights code so it's more understandable
oh my fault i cant think rn
Gucchi:
and i want to encode this quote: You miss 100% of the shots you don't take.
Gucchi:
i just started learning this rn and it looks kind of hard
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Ultrilliam:
Alright, let's start with number 2.
First you need to put the quote you want into a string/variable.
Then you need to loop through each character in the string and run the command `ord` which converts it into the ASCII value of the character, take the result of that and push it to an array.
Then, print that array.
That should get you the encoded message seen in the example.
To decode it, do it in reverse,
loop through the array,
run each value through chr to convert it back to text,
combine together the strings,
output to user.
That will get you the assignment without the optional objective.
Gucchi:
@ultrilliam wrote:
Alright, let's start with number 2.
First you need to put the quote you want into a string/variable.
Then you need to loop through each character in the string and run the command `ord` which converts it into the ASCII value of the character, take the result of that and push it to an array.
Then, print that array.
That should get you the encoded message seen in the example.
To decode it, do it in reverse,
loop through the array,
run each value through chr to convert it back to text,
combine together the strings,
output to user.
That will get you the assignment without the optional objective.
can you give me an example of how you can use the ord command?
Gucchi:
@ultrilliam wrote:
Alright, let's start with number 2.
First you need to put the quote you want into a string/variable.
Then you need to loop through each character in the string and run the command `ord` which converts it into the ASCII value of the character, take the result of that and push it to an array.
Then, print that array.
That should get you the encoded message seen in the example.
To decode it, do it in reverse,
loop through the array,
run each value through chr to convert it back to text,
combine together the strings,
output to user.
That will get you the assignment without the optional objective.
im very confused on how i should code this, can you put all that in code form so i understand more easily?
Gucchi:
if your going to answer this rn please let me know cuz its 12am where i am and im just waiting for your comments man
Gucchi:
ive been working all day
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Ultrilliam:
Apologies for the delay, I actually went to take a shower after my previous comment. Anywho, I'm not going to give it to you in code because it would basically be giving you the answer or the assignment. I already explained what ord does, but like any function it's utilized like this:
```py
ord("x")
```
in this case, the ord function actually only accepts character, rather than a full string. The function returns the ASCII value of the character. Similarly, `chr()` can be used to convert the value that ord returns, back into text.
Does this make sense now?
Gucchi:
alr yh it makes sense now so when you said loop through each character, do you mean like every word in the quote? for example, You miss 100% of the shots you don't take is the quote so i would loop the first character which is "f"?
Gucchi:
also can you give me an idea on how to make an array?
Gucchi:
@ultrilliam wrote:
Apologies for the delay, I actually went to take a shower after my previous comment. Anywho, I'm not going to give it to you in code because it would basically be giving you the answer or the assignment. I already explained what ord does, but like any function it's utilized like this:
```
ord("x")
```
in this case, the ord function actually only accepts character, rather than a full string. The function returns the ASCII value of the character. Similarly, `chr()` can be used to convert the value that ord returns, back into text.
Does this make sense now?
no worries btw
Ultrilliam:
yea, you can loop through a string with a for loop, then execute something on that character. As for an array, you can create an array like this:
```
varname = []
```
You can then add stuff to the array with the Array.append() method.
```
varname.append("data")
```
You can loop through an array with a for loop, similar to how you can for a string.
Though I feel like this is stuff you should have been taught in your class already before being given this assignment?
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Gucchi:
@ultrilliam wrote:
yea, you can loop through a string with a for loop, then execute something on that character. As for an array, you can create an array like this:
```
varname = []
```
You can then add stuff to the array with the Array.append() method.
```
varname.append("data")
```
You can loop through an array with a for loop, similar to how you can for a string.
Though I feel like this is stuff you should have been taught in your class already before being given this assignment?
thats the thing, they give modules and lessons but its no help. i even tried communicating with my teacher, but she doesnt respond. thats why i use this now
Gucchi:
and she just contacted me the other day and told me that i had to finish everything by friday
Gucchi:
i was like Cakef you mean friday i still got like 4 assignments left
Gucchi:
and yh now its hard cuz i gotta stay up doin this
Gucchi:
@ultrilliam wrote:
yea, you can loop through a string with a for loop, then execute something on that character. As for an array, you can create an array like this:
```
varname = []
```
You can then add stuff to the array with the Array.append() method.
```
varname.append("data")
```
You can loop through an array with a for loop, similar to how you can for a string.
Though I feel like this is stuff you should have been taught in your class already before being given this assignment?
ill try this
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Gucchi:
def main():
myMISSquote = "You miss 100% of the shots you don't take"
quoteList = []
for eachCharacter in myMISSquote:
quoteList.append(ord(eachCharacter))
for c in quoteList:
print(c),
decodeMyMISSquote = ""
for m in quoteList:
decodeMyMISSquote = decodeMyMISSquote + chr(m)
print("")
print decodeMyMISSquote
main()
More or less, but you could have just printed the array I believe instead of looping through the array to print that. Also you forgot to put it in codeblocks, again
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Ultrilliam:
This is how it looks in a codeblock:
```py
def main():
myMISSquote = "You miss 100% of the shots you don't take"
quoteList = []
for eachCharacter in myMISSquote:
quoteList.append(ord(eachCharacter))
for c in quoteList:
print(c),
decodeMyMISSquote = ""
for m in quoteList:
decodeMyMISSquote = decodeMyMISSquote + chr(m)
print("")
print decodeMyMISSquote
main()
```