# you need to import QSlider from PyQt5.QtWidgets first
from PyQt5.QtWidgets import QSlider
layout = QVBoxLayout() # or QHBoxLayout
slider = QSlider(Qt.Horizontal) # or Qt.Vertical
slider.setMinimum(10) # set min limit
slider.setMaximum(30) # set max limit
slider.setValue(20) # initiate value
slider.setTickPosition(QSlider.TicksBelow) # set the Ticks at below the slider
slider.setTickInterval(5) # set Tick Interval
layout.addWidget(slider) # finally add it to your layout