What do these programs print? What is significant about the output of the two programs?
Program 1
list=[1, 2, 3, 1, "hi", "hello"]
list.sort()
print list
list.reverse()
print list
Program 2
list=[1, 2, 3, 1, "hi", "hello"]
list.reverse()
print list
list.sort()
print list
[1, 1, 2, 3, 'hello', 'hi']
ReplyDelete['hi', 'hello', 3, 2, 1, 1]
['hello', 'hi', 1, 3, 2, 1]
[1, 1, 2, 3, 'hello', 'hi']
jonathan
1,1,2,3,hi,hello
ReplyDeletehello,hi,3,2,1,1
hello,hi,1,3,2,1
hi,hello,1,1,2,3
Charlie Lin
1
ReplyDelete1 1 2 3 hello hi
hi hello 3 2 1 1
2
hello hi 1 3 2 1
1 1 2 3 hello hi
Program 1 sorts it and then reverses the sorted list
Program 2 reverses the list's original order and then sorts it
["hello","hi",1,3,2,1]
ReplyDelete["hi","hello",1,1,2,3]
---Lux lei
1.
ReplyDelete[1, 1, 2, 3, "hello", "hi"]
["hi", "hello", 3, 2, 1, 1]
2.
["hello", "hi", 1, 3, 2, 1]
[1, 1, 2, 3, "hello", "hi"]
The order of the sort and reverse commands changes the order of the second print in each function.
Josh Lee
Program 1:
ReplyDelete[1,1,2,3,"hello", "hi"]
["hi","hello",3,2,1,1]
Program 2:
["hello","hi",1,3,2,1]
[1,1,2,3,"hello","hi"]
Program 1 ends with list equaling the original values being ordered in reverse python order. Program 2 ends with the original values in python order. The sort at the end of Program 2 negates the reverse before it.
-Katelyn
[1, 1, 2, 3, 'hello', 'hi']
ReplyDelete['hi', 'hello', 3, 2, 1, 1]
['hello', 'hi', 1, 3, 2, 1]
[1, 1, 2, 3, 'hello', 'hi']
they sorted and reversed the lists in a different order
jonathan
program 1
ReplyDelete1,1,2,3,"hello","hi"
"hi","hello",3,2,1,1
program 2
"hello","hi",1,3,2,1
1,1,2,3,"hello","hi"
They are significant, They are different because the first one is sorted then reverse, but the second one is reverse then sorted which undoes the reverse into a sorted order
-Sean
Program 1
ReplyDelete[1,1,2,3,"hello","hi"]
["hi","hello",3,2,1,1]
Program 2
["hello","hi",1,3,2,1]
[1,1,2,3,"hello","hi"]
reverse doesn't sort on its own
_Ben
[1,1,2,3,"hi","hello"]
ReplyDelete["hello","hi",3,2,1,1]
["hello","hi",1,3,2,1]
["hello","hi",3,2,1,1]
-Gary
Program 1
ReplyDelete1,1,2,3, "hello", "hi"
"hi", "hello", 3,2,1,1
Program 2
"hello", "hi", 1,3,2,1
1,1,2,3, "hello", "hi"
They're significant because the last line in program 2 is the first line in program 1.
Alex Haston
Prog 1:
ReplyDelete1,1, 2, 3, ,"hello", "hi"
"hi", "hello", 3, 2, 1, 1
Prog 2:
"Hello","hi",1,3,2,1
1,1, 2, 3, ,"hello", "hi"
These two are different because in the first we sorted the list then reversed it where in the second one we reversed it first then sorted. This causes the second program to be opposite of what the first program is, and remding the reverse command useless.
-Joe Haj
[1,1,2,3,"hello","hi"]
ReplyDelete["hi","hello",3,2,1,1]
~Travis Vonheeder
Chris VanYe
ReplyDelete[1,1,2,3,"hello","hi"]
["hi","hello",3,2,1,1]
["hello","hi",1,3,2,1]
[1,1,2,3,"hello","hi"]
when you sort ad then reverse, it prints the reverse order. if you reverse and then sort, the sort undoes anything that the reverse did when it sorts it.
["hi", "hello", 3, 2, 1, 1]
ReplyDelete[1, 1, 2, 3, "hello", "hi"]
The significant difference is Program 1 is in descending sorted order and Program 2 is in ascending sorted order.
- Abby Peterson
[1, 1, 2, 3, 'hello', 'hi']
ReplyDelete['hi', 'hello', 3, 2, 1, 1]
['hello', 'hi', 1, 3, 2, 1]
[1, 1, 2, 3, 'hello', 'hi']
-Owen Luther