CSC201 PRACTICAL - Print TH-WPS Office-1
CSC201 PRACTICAL - Print TH-WPS Office-1
import pytz
tz = pytz.timezone('Africa/Lagos')
current_time = datetime.now(tz)
import datetime
now = datetime.datetime.now()
print(now.strftime("%Y-%m-%d %H:%M:%S"))
print("Current year:")
print(now.year)
3##### Here is a Python code to display the calendar for the year 2024 using the `calendar` module:
```python
import calendar
year = 2024
cal = calendar.TextCalendar(calendar.SUNDAY)
print(cal.formatmonth(year, month))
```
When you run this code, it will display the calendar for each month in the year 2024. Each month is
displayed in a grid format with the days of the week and dates listed.
4#### Here is a Python code snippet to calculate the area of a triangle given its base and height:
To calculate the area of a triangle given its base and height, you can use the formula:
Here is the Python code snippet to calculate the area of a triangle with a base of 25 and a height of 16:
```python
base = 25
height = 16
```
```
The area of the triangle with base 25 and height 16 is: 200.0
```
Therefore, the area of the triangle with a base of 25 and a height of 16 is 200 square units.
5#### write a python program to add two numbers and print the output
Here is a simple Python code that adds two numbers and prints the output:
```python
num1 = 10
num2 = 20
```
In this code, we input two numbers (10 and 20 in this case), add them together, and then print the sum.
You can change the values of `num1` and `num2` to add any two numbers you like.