I'm in a Python Programming course right now, and I know there is a classroom forum, but this isn't about an assignment, rather about the format not working properly only for the students using Mac OS (myself included).
So, if we type:
numbers = [ ]
strings = [ ]
names = ["John", "Eric", "Jessica"]
numbers.append(1)
numbers.append(2)
numbers.append(3)
strings.append('hello')
strings.append('world')
second_name = names[1]
print(numbers)
print(strings)
print(names)
print(names[1])
print(names[2])
print(strings[0] + " " + strings[1])
print(strings[0] + " " + names[2])
In the console it shows:
[1, 2, 3]
['hello', 'world']
['John', 'Eric', 'Jessica']
Eric
Jessica
hello world
hello Jessica
Now with all of that typed in, here's where the format gets messed up.
When we try to have Python print strings and numbers, it no longer shows up properly on the console.
Typing this:
print(strings[0], numbers[1])
Produces this:
('hello', 2)
Now, if we remove the parenthesis and instead type:
print strings[0], numbers[1]
Then, we get what we actually want in the console:
hello 2
There's obviously an error code that is then received, since the print format is supposed to have the parenthesis.
This also happened when we did the code with somewhat different variables:
myfloat = 10.0
myint = 20
sumNumbers = myfloat + myint
mystring = "hello"
Saying = "Saying"
t = "times"
mystring2 = "will give you"
print(Saying + " " + mystring)
print(myint)
print(myfloat)
print(mystring2)
print(Saying + " " + mystring, myint, t, myfloat, mystring2, sumNumbers)
print Saying + " " + mystring, myint, t, myfloat, mystring2, sumNumbers
s = 'Saying' + " " + 'hello'
t = 'will give you'
u = 'times'
print (s, myint, u, myfloat, t, sumNumbers)
print s, myint, u, myfloat, t, sumNumbers
These prints produce:
Saying hello
20
10.0
will give you
('Saying hello', 20, 'times', 10.0, 'will give you', 30.0)
Saying hello 20 times 10.0 will give you 30.0
('Saying hello', 20, 'times', 10.0, 'will give you', 30.0)
Saying hello 20 times 10.0 will give you 30.0
So, to summarize the issue, when separating words and numbers, print works perfectly fine with what we want to appear in the console, but when we use the format to combine the two (like we're supposed to), then we have the quotations, commas, and parenthesis showing up.
We all have the latest Mac OS X, along with Python 3 and Eclipse Photon (with the IDE for Java Developers, and PyDev).
Any help would be extremely useful. Thank you in advance and have a wonderful day.
So, if we type:
numbers = [ ]
strings = [ ]
names = ["John", "Eric", "Jessica"]
numbers.append(1)
numbers.append(2)
numbers.append(3)
strings.append('hello')
strings.append('world')
second_name = names[1]
print(numbers)
print(strings)
print(names)
print(names[1])
print(names[2])
print(strings[0] + " " + strings[1])
print(strings[0] + " " + names[2])
In the console it shows:
[1, 2, 3]
['hello', 'world']
['John', 'Eric', 'Jessica']
Eric
Jessica
hello world
hello Jessica
Now with all of that typed in, here's where the format gets messed up.
When we try to have Python print strings and numbers, it no longer shows up properly on the console.
Typing this:
print(strings[0], numbers[1])
Produces this:
('hello', 2)
Now, if we remove the parenthesis and instead type:
print strings[0], numbers[1]
Then, we get what we actually want in the console:
hello 2
There's obviously an error code that is then received, since the print format is supposed to have the parenthesis.
This also happened when we did the code with somewhat different variables:
myfloat = 10.0
myint = 20
sumNumbers = myfloat + myint
mystring = "hello"
Saying = "Saying"
t = "times"
mystring2 = "will give you"
print(Saying + " " + mystring)
print(myint)
print(myfloat)
print(mystring2)
print(Saying + " " + mystring, myint, t, myfloat, mystring2, sumNumbers)
print Saying + " " + mystring, myint, t, myfloat, mystring2, sumNumbers
s = 'Saying' + " " + 'hello'
t = 'will give you'
u = 'times'
print (s, myint, u, myfloat, t, sumNumbers)
print s, myint, u, myfloat, t, sumNumbers
These prints produce:
Saying hello
20
10.0
will give you
('Saying hello', 20, 'times', 10.0, 'will give you', 30.0)
Saying hello 20 times 10.0 will give you 30.0
('Saying hello', 20, 'times', 10.0, 'will give you', 30.0)
Saying hello 20 times 10.0 will give you 30.0
So, to summarize the issue, when separating words and numbers, print works perfectly fine with what we want to appear in the console, but when we use the format to combine the two (like we're supposed to), then we have the quotations, commas, and parenthesis showing up.
We all have the latest Mac OS X, along with Python 3 and Eclipse Photon (with the IDE for Java Developers, and PyDev).
Any help would be extremely useful. Thank you in advance and have a wonderful day.