Setup:

<< Graphics`Graphics`

colors = 
      {red, green, blue, cyan, magenta, yellow, black} = 
        
{RGBColor[1, 0, 0], 
          
RGBColor[0, 1, 0], 
          
RGBColor[0, 0, 1], 
          
CMYKColor[1, 0, 0, 0], 
          
CMYKColor[0, 1, 0, 0], 
          
CMYKColor[0, 0, 1, 0], 
          
CMYKColor[0, 0, 0, 1]}; 
Protect[colors, red, green, blue, cyan, magenta, yellow, black];

Plot[Table[i x, {i, 1, 7}]  // Evaluate, {x, 0, 1}, 
      PlotStyle -> colors];

Example 1:

Clear["Global`*"]

Plot the sample function:

Clear[f];
f[x_]:=x /; x <= N[Pi];
f[x_]:=0 /; x >= N[Pi];

Plot[f[x],{x,0,2 Pi}];

Compute the Fourier coefficients

c[0]= 1/(2 Pi) Integrate[ x  ,{x,0,1 Pi}]

c[m_]= 1/(2 Pi) Integrate[ x Exp[- I m x] ,{x,0,1 Pi}] //FullSimplify

term[0]= c[0];

term[m_]= c[m] Exp[I m x] + c[-m]  Exp[-I m x]  //Simplify

series[n_]:= Sum[ term[m] ,{m,0,n}]

Plot the series with different numbers of terms

Plot[ Join[{f[x]},Table[series[i],{i,2,5,1}] ] //Evaluate
  ,{x,0,2 Pi},PlotStyle->colors];

Plot[ {f[x], series[30] } //Evaluate ,{x,0,2 Pi}];

Make  a "frequency domain" plot of the coefficients

coeffs = Table[{Re[c[i]], Im[c[i]]}, {i, 0, 5}]  // Flatten

?blue

BarChart[coeffs, BarStyle -> {red, blue}, 
      BarLabels -> {"Re", "Im"}];

Re-write the Exp series as a Trig series

term2[0] = term[0] //ExpToTrig //Simplify

term2[m_]= term[m] //ExpToTrig //FullSimplify

series2[n_]:= Sum[ term2[m] ,{m,0,n}]

series[5]

series2[5]

series2[5]  // TrigReduce

Verify that they are identical

series2[5] - series[5]  // FullSimplify

Problem 1: f[x_]=x  for x=[0,2 π]

Clear["Global`*"]

Part a)

Clear[f];
f[x_]:=x;

Plot[f[x],{x,0,2 Pi}];

Problem 2: f[x_]=...  for x=[0,2 π]

Clear["Global`*"]

Part a)

Clear[f];
f[x_]:=1 /; x <= N[Pi];
f[x_]:=0 /; x >= N[Pi];

Plot[f[x],{x,0,2 Pi}];

Problem 3: f[x_]=...  for x=[0,2 π]

Clear["Global`*"]

Part a)

Clear[f];
f[x_]:=Sin[x] /; x <= N[Pi];
f[x_]:=0 /; x >= N[Pi];

Plot[f[x],{x,0,2 Pi}];

Problem 4&5: 
By hand, compute the Sin coefficients for problems #1 and #2 in Hwk3.