score:9
The tram (as any in Bonn) will have a ticket machine inside but be aware that it only takes coins. If you take a bus you can pay at the driver. The price at the moment is 2.80β¬ for a single trip.
You can also buy ticket beforehand at any of these shops or these counters but most (if not all) are likely closed in the evening.
Do not buy a ticket from a machine if you don't plan to travel immediately as tickets from a machine are directly validated.