In: Computer Science
This is all that was given.
Write a program in a PL of your choice to create the followings Output:
A table(7 rows), you see below, showing 35 names grouped in 7
lines.
The first column is the chosen Programming Language to develop and
present by the group.
PLs All group Names
C n26 n06 n28 n16 n30
C++ n31 n07 n33 n17 n35
C# n03 n08 n13 n18 n23
Python n04 n09 n14 n19 n24
java n05 n10 n15 n20 n25
JS n01 n27 n11 n29 n21
Ruby n02 n32 n12 n34 n22
Do you need more ? <0,1>1
PLs All group Names
C n01 n31 n11 n04 n21
C++ n02 n07 n12 n09 n22
C# n28 n33 n13 n14 n15
Python n16 n17 n18 n19 n20
java n30 n35 n23 n24 n25
JS n26 n27 n03 n29 n05
Ruby n06 n32 n08 n34 n10
Do you need more ? <0,1>0
- Names are unique, they should not be duplicated as this (nam7, name7), they can be real student names.
- The program should allow the user to rearrange the students
and the groups at will.
Example: select many students in one of several groups
:
if(( student_numbers %7) ==0 ) set student in group 1 (first group), and
if ((student_numbers %7) ==1 ) in group 2 (second group)
if ((student_numbers %7) ==2 ) in group 3 (third group)
if ((student_numbers %7) ==3 ) in group 4 (fourth group)
if (((student_numbers %7) ==4) in group 5 (fifth group)
if ((student_numbers %7 )==5) in group 6 (sixth group)
if ((student_numbers %7) ==6) in group 7 (seventh group)
Note: here % modulo function was used, but we can use other methods
of classification (formula, or function like).
Assignment: (Write a program in any PL and submit. (Required for grading))
------------------------------------------------------------------
Here is a pdf (repeated copy):
-------------------------------------
Write a program in a PL of your choice to create the followings
Output:
A table (7 rows), you see below, showing 35 names grouped in 7
lines.
The first column is the chosen Programming Language to develop and
present by the group.
- Names are unique, they should not be duplicated as this (nam7,
name7), they can be real
student names.
- The program should allow the user to rearrange the students and
the groups at will.
Example: select many students in one of several groups:
If (( student_numbers %7) ==0) set student in group 1 (first
group), and
if ((student_numbers %7) ==1) in group 2 (second group)
if ((student_numbers %7) ==2) in group 3 (third group)
if ((student_numbers %7) ==3) in group 4 (fourth group)
if (((student_numbers %7) ==4) in group 5 (fifth group)
if ((student_numbers %7) ==5) in group 6 (sixth group)
if ((student_numbers %7) ==6) in group 7 (seventh group)
Note: here % modulo function was used, but we can use other methods
of classification
(formula, or function like).
Assignment: (Write a program in any PL and submit. (Required for
grading))
Input: list of PLs, and list of student names (generate these at
random)
Output: the given Table (format) you see above
import random
# function to generate random students
def generate():
l=[]
ll=[]
c=0
while c<35:
a=random.randint(1,35)
while a in l:
a=random.randint(1,35)
l.append(a)
ll.append(a)
if(len(ll)==5):
students1.append(ll)# list of group of 5 students
ll=[]
students.append(a)# list of all random generated students
c=c+1
# function to rearrange students in groups
def rearrange():
l=[]
l1=[]
l2=[]
l3=[]
l4=[]
l5=[]
l6=[]
# rearrange students in each group
for i in students:
if i%7==0:# group 1
l.append(i)
elif i%7==1:# group 2
l1.append(i)
elif i%7==2:# group 3
l2.append(i)
elif i%7==3:# group 4
l3.append(i)
elif i%7==4:# group 5
l4.append(i)
elif i%7==5:# group 6
l5.append(i)
else:# group 7
l6.append(i)
students2.append(l)
students2.append(l1)
students2.append(l2)
students2.append(l3)
students2.append(l4)
students2.append(l5)
students2.append(l6)
#function to display PL and students group wise
def display(l):
c=0
for i in l:
print(pl[c],end=' ')
c=c+1
for j in i:
s='n'+str(j)
print(s,end=' ')
print()
# list of PLs
pl=['C','C++','C#','Python','Java','JS','Ruby']
students=[]
students1=[]
# list to store rearranged list of list of students
students2=[]
n=1
while n==1:
students=[]
students1=[]
students2=[]
generate()
flag=int(input("Do you want to rearrange students and groups? <0,1> "))
print('PLs All group Names')
if flag==1:# if user asks to rearrange
rearrange()
display(students2)
else:
display(students1)
n=int(input("Do you need more ? <0,1> "))