% https://www.sharelatex.com/learn/Sections_and_chapters
%\titleformat{<command>}[<shape>]{<format>}{<label>}{<sep>}{<before-code>}[<after-code>]
%\titlespacing{<command>}{<left>}{<before-sep>}{<after-sep>}

\documentclass[a4paper,12pt]{book}
%\setlength{\parindent}{0pt}
%\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

\usepackage{titlesec}

%%%%%%%%%%%%%% chapter
 
\titleformat
{\chapter} % command
[block] % shape
{\bfseries\LARGE\scshape} % format
{Chapter No. \ \thechapter} % label
{0.5ex} % sep
{   \rule{\textwidth}{0.3pt}
    \vspace{1ex}
    \centering
} % before-code
[\vspace{-1ex}%
\rule{\textwidth}{0.3pt}
] % after-code
 

 
\titleformat{\section}[frame]
{\normalfont\itshape}
{\thesection.}{1em}{}
 
\titlespacing{\section}{12pc}{1.5ex plus .1ex minus .2ex}{1pc}
 
 
\begin{document}
 
\chapter{Let's begin}

 
\section{First Attempt}
 
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do 
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
enim ad minim veniam, quis nostrud exercitation ullamco laboris...

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do 
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
enim ad minim veniam, quis nostrud exercitation ullamco laboris...
 
\section{Second Attempt}
 
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do 
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
enim ad minim veniam, quis nostrud exercitation ullamco laboris...
 
\end{document}

