Please rewrite the code given below and written in C, in Python. #include #include int main(int argc, char *argv[]) { int chart[10][5]; int employeeArray[6]; int employee, employee1, employee2; int sec,i; srand(time(NULL)); do{ select=monu(); switch(selection) { case 0: printf("Program Terminated"); break; case 1: fill(table, employeeArray); print chart(schedule); break; case 2: printf("\nEnter Employees to Replace:"); scanf("%d%d",&work1,&work2); change(schedule,employee1,worker2); break; case 3: printf("\nAre you to be asked for Weekly Work Details?"); scanf("%d",&working); dayMonthSummer(schedule,employee); break; default: printf("\n Incorrect entry \a\n"); } }while(choice!=0); return 0; } int monu() { int select; printf("\n_____MONU_____ \n"); printf("0- Close Program\n"); printf("1- Print Weekly Schedule \n"); printf("2- Swap Employees\n"); printf("3- Get Employee Weekly Work Details\n"); printf("___________\n"); printf("Your choice: "); scanf("%d",&select); return choice; } void fill(int array[][5],int array2[]) { int i; int n; for(i=1;i<6;i++) { array2[i]=10; } printf("\n"); int value;//generated EmployeeCode for(n=0;n<10;n++){ for(i=0;i<5;++i) { value=rand() 5% + 1; if(employeeControl(array2,value)==-1){ I--; continue; } else array[n][i]=value; } } } int runningControl(int generatedValue[],int value) { if(generatedValue[value]!=0) { generatedValue[value]--; return 1; } else return -1; } int print chart(int array[][5]) { printf("\t Monday Tuesday Wednesday Thursday Friday\n"); int n, i; for(n=0;n<10;n++){ printf("%d. Range:\t",n+1); for(i=0;i<5;++i) { printf("%d\t",array[n][i]); } printf("\n"); } } void replace(int array[][5],int c1,int c2) { int n,i; int array2[10][5]={0}; for(n=0;n<10;n++){ for(i=0;i<5;++i) { if(array[n][i]==c2) array2[n][i]=c2; } } for(n=0;n<10;n++){//Overwrite in the Array 10 points for(i=0;i<5;++i) { if(array[n][i]==c1) { array[n][i]=c2; } } } for(n=0;n<10;n++){//Finally, the backup is transferred to the main table 15 points for(i=0;i<5;++i) { if(array[n][i]-array2[n][i]==0) { array[n][i]=c1; } } } printf("Operation Done\n"); printtable(array); } void gunMonth(int array[][5],int c) { int n,m; for(n=0;n<10;n++) for(m=0;m<5;m++) if(array[n][m]==c) { printf("%d. Range\t",n+1); gunCall(m); printf("\n"); } } void dayCall(int n) { switch(n) { case 0: printf("Monday"); break; case 1: printf("Tuesday"); break; case 2: printf("Wednesday"); break; case 3: printf("Thursday"); break; case 4: printf("Friday"); break; } }
Please rewrite the code given below and written in C, in Python.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int chart[10][5];
int employeeArray[6];
int employee, employee1, employee2;
int sec,i;
srand(time(NULL));
do{
select=monu();
switch(selection)
{
case 0:
printf("Program Terminated");
break;
case 1:
fill(table, employeeArray);
print chart(schedule);
break;
case 2:
printf("\nEnter Employees to Replace:");
scanf("%d%d",&work1,&work2);
change(schedule,employee1,worker2);
break;
case 3:
printf("\nAre you to be asked for Weekly Work Details?");
scanf("%d",&working);
dayMonthSummer(schedule,employee);
break;
default:
printf("\n Incorrect entry \a\n");
}
}while(choice!=0);
return 0;
}
int monu()
{
int select;
printf("\n_____MONU_____ \n");
printf("0- Close Program\n");
printf("1- Print Weekly Schedule \n");
printf("2- Swap Employees\n");
printf("3- Get Employee Weekly Work Details\n");
printf("___________\n");
printf("Your choice: ");
scanf("%d",&select);
return choice;
}
void fill(int array[][5],int array2[])
{
int i;
int n;
for(i=1;i<6;i++)
{
array2[i]=10;
}
printf("\n");
int value;//generated EmployeeCode
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
value=rand() 5% + 1;
if(employeeControl(array2,value)==-1){
I--;
continue;
}
else
array[n][i]=value;
}
}
}
int runningControl(int generatedValue[],int value)
{
if(generatedValue[value]!=0)
{
generatedValue[value]--;
return 1;
}
else
return -1;
}
int print chart(int array[][5])
{
printf("\t Monday Tuesday Wednesday Thursday Friday\n");
int n, i;
for(n=0;n<10;n++){
printf("%d. Range:\t",n+1);
for(i=0;i<5;++i)
{
printf("%d\t",array[n][i]);
}
printf("\n");
}
}
void replace(int array[][5],int c1,int c2)
{
int n,i;
int array2[10][5]={0};
for(n=0;n<10;n++){
for(i=0;i<5;++i)
{
if(array[n][i]==c2)
array2[n][i]=c2;
}
}
for(n=0;n<10;n++){//Overwrite in the Array 10 points
for(i=0;i<5;++i)
{
if(array[n][i]==c1)
{
array[n][i]=c2;
}
}
}
for(n=0;n<10;n++){//Finally, the backup is transferred to the main table 15 points
for(i=0;i<5;++i)
{
if(array[n][i]-array2[n][i]==0)
{
array[n][i]=c1;
}
}
}
printf("Operation Done\n");
printtable(array);
}
void gunMonth(int array[][5],int c)
{
int n,m;
for(n=0;n<10;n++)
for(m=0;m<5;m++)
if(array[n][m]==c)
{
printf("%d. Range\t",n+1);
gunCall(m);
printf("\n");
}
}
void dayCall(int n)
{
switch(n)
{
case 0:
printf("Monday");
break;
case 1:
printf("Tuesday");
break;
case 2:
printf("Wednesday");
break;
case 3:
printf("Thursday");
break;
case 4:
printf("Friday");
break;
}
}
Step by step
Solved in 2 steps with 2 images