-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSocket Module and DateTime Module Overview
More file actions
642 lines (524 loc) · 23.2 KB
/
Socket Module and DateTime Module Overview
File metadata and controls
642 lines (524 loc) · 23.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# Python Socket and DateTime Modules: Complete Beginner Guide
# =============================================================================
# USING HELP() - YOUR FIRST STEP TO UNDERSTANDING MODULES
# =============================================================================
import socket
import datetime
from datetime import datetime as dt
print("--- Using help() to Understand Modules ---")
print("Before diving into any module, use help() to get documentation:")
print(" help(socket) - Shows all socket module functions and classes")
print(" help(datetime) - Shows all datetime module functions and classes")
print(" help(socket.socket) - Shows specific socket class documentation")
print(" help(datetime.datetime) - Shows specific datetime class documentation")
print("\nExample: Getting help for socket module")
print(">>> help(socket)")
print("This would show you all available functions like:")
print(" - socket() - Create a socket object")
print(" - gethostname() - Get the current hostname")
print(" - gethostbyname() - Get IP address from hostname")
print("\nExample: Getting help for datetime module")
print(">>> help(datetime)")
print("This would show you all available classes like:")
print(" - datetime - Main datetime class")
print(" - date - Date-only class")
print(" - time - Time-only class")
print(" - timedelta - Time difference class")
# =============================================================================
# SOCKET MODULE - NETWORK COMMUNICATION
# =============================================================================
print("\n" + "="*60)
print("SOCKET MODULE - NETWORK COMMUNICATION")
print("="*60)
print("--- Understanding the Socket Module ---")
print("The socket module allows programs to communicate over networks.")
print("Think of a socket as a 'telephone' for programs to talk to each other.")
print("Key concepts:")
print(" - SERVER: Program that waits for connections (like answering phone)")
print(" - CLIENT: Program that connects to server (like making phone call)")
print(" - ADDRESS: Where to find the server (IP address + port number)")
# =============================================================================
# CREATING A SOCKET
# =============================================================================
print("\n--- Creating a Socket ---")
print("To create a socket, use: socket.socket(family, type)")
# Create different types of sockets
print("\nMost common socket creation:")
print("server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)")
print("Explanation:")
print(" - socket.AF_INET: Use IPv4 internet protocol")
print(" - socket.SOCK_STREAM: Use TCP (reliable, ordered data)")
# Demonstrate socket creation
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(f"Created server socket: {server_socket}")
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(f"Created client socket: {client_socket}")
print("\nOther socket types you might see:")
print("socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP socket (faster, less reliable)")
print("socket.socket(socket.AF_INET6, socket.SOCK_STREAM) # IPv6 TCP socket")
# =============================================================================
# BIND - ASSIGNING AN ADDRESS TO A SOCKET
# =============================================================================
print("\n--- Understanding bind() ---")
print("bind() assigns an address (IP + port) to a socket")
print("Think of it like: 'My phone number is 555-1234'")
print("Usage: socket.bind((host, port))")
print("\nCommon bind examples:")
print("server_socket.bind(('localhost', 8080))")
print(" - Binds to localhost (this computer only) on port 8080")
print("server_socket.bind(('', 8080))")
print(" - Binds to all available network interfaces on port 8080")
print("server_socket.bind(('192.168.1.100', 9000))")
print(" - Binds to specific IP address on port 9000")
# Demonstrate bind (but don't actually bind to avoid conflicts)
print(f"\nExample bind operation:")
print(f"server_socket.bind(('localhost', 12345))")
print("This tells the system: 'Reserve port 12345 for this socket'")
# =============================================================================
# LISTEN - WAITING FOR CONNECTIONS
# =============================================================================
print("\n--- Understanding listen() ---")
print("listen() makes a socket ready to accept incoming connections")
print("Think of it like: 'I'm ready to answer phone calls'")
print("Usage: socket.listen(backlog)")
print("\nCommon listen examples:")
print("server_socket.listen(5)")
print(" - Ready to accept connections, queue up to 5 waiting connections")
print("server_socket.listen(1)")
print(" - Accept one connection at a time")
print("server_socket.listen()")
print(" - Use system default (usually reasonable)")
print(f"\nWhat happens when you call listen():")
print("1. Socket becomes a 'listening socket'")
print("2. It can now receive connection requests")
print("3. Multiple clients can try to connect")
print("4. System queues connection requests up to the backlog limit")
# =============================================================================
# ACCEPT - ACCEPTING CONNECTIONS
# =============================================================================
print("\n--- Understanding accept() ---")
print("accept() waits for a client to connect and returns a new socket")
print("Think of it like: 'Answer the phone when it rings'")
print("Usage: new_socket, address = socket.accept()")
print("\nWhat accept() returns:")
print("client_socket, client_address = server_socket.accept()")
print(" - client_socket: New socket to communicate with this specific client")
print(" - client_address: Tuple with client's IP and port (where they're calling from)")
print(f"\nExample accept() scenario:")
print("client_socket, addr = server_socket.accept()")
print("print(f'Connected to client at {addr}')")
print("# This would print something like: 'Connected to client at ('192.168.1.50', 54321)'")
print(f"\nImportant: accept() is BLOCKING")
print("- The program stops and waits until a client connects")
print("- Like waiting by the phone until it rings")
# =============================================================================
# SEND AND SENDALL - SENDING DATA
# =============================================================================
print("\n--- Understanding send() and sendall() ---")
print("These functions send data through a socket connection")
print("Think of it like: 'Speaking into the phone'")
print("\n--- send() function ---")
print("Usage: bytes_sent = socket.send(data)")
print("- Sends some or all of the data")
print("- Returns number of bytes actually sent")
print("- Might not send all data in one call!")
print("\nExample send() usage:")
print("message = 'Hello Client!'")
print("data = message.encode('utf-8') # Convert string to bytes")
print("bytes_sent = client_socket.send(data)")
print("print(f'Sent {bytes_sent} bytes')")
print("\n--- sendall() function ---")
print("Usage: socket.sendall(data)")
print("- Sends ALL the data (keeps trying until everything is sent)")
print("- Returns None on success, raises exception on error")
print("- Usually what you want to use!")
print("\nExample sendall() usage:")
print("message = 'Hello Client!'")
print("data = message.encode('utf-8') # Convert string to bytes")
print("client_socket.sendall(data) # Sends everything")
print("print('All data sent successfully')")
print("\nKey differences:")
print(" send() - Might send partial data, you need to check return value")
print(" sendall() - Guarantees all data is sent, easier to use")
# =============================================================================
# RECV - RECEIVING DATA
# =============================================================================
print("\n--- Understanding recv() ---")
print("recv() receives data from a socket connection")
print("Think of it like: 'Listening to what the other person says'")
print("Usage: data = socket.recv(buffer_size)")
print("\nCommon recv() examples:")
print("data = client_socket.recv(1024)")
print(" - Receives up to 1024 bytes of data")
print(" - Returns bytes object (not string!)")
print(" - Returns empty bytes b'' if connection is closed")
print("data = client_socket.recv(4096)")
print(" - Receives up to 4096 bytes (larger buffer)")
print("\nImportant recv() behaviors:")
print("1. recv() is BLOCKING - waits until data arrives")
print("2. Might receive less data than requested")
print("3. Returns bytes, not strings")
print("4. Returns empty bytes when connection closes")
print("\nComplete recv() example:")
print("data = client_socket.recv(1024)")
print("if data:")
print(" message = data.decode('utf-8') # Convert bytes to string")
print(" print(f'Received: {message}')")
print("else:")
print(" print('Connection closed by client')")
print("\nReceiving larger messages (loop pattern):")
print("def receive_all(sock, length):")
print(" data = b''")
print(" while len(data) < length:")
print(" chunk = sock.recv(length - len(data))")
print(" if not chunk:")
print(" break")
print(" data += chunk")
print(" return data")
# =============================================================================
# CLOSE - CLOSING CONNECTIONS
# =============================================================================
print("\n--- Understanding close() ---")
print("close() closes a socket connection")
print("Think of it like: 'Hanging up the phone'")
print("Usage: socket.close()")
print("\nWhen to use close():")
print("1. After you're done communicating")
print("2. When an error occurs")
print("3. In a finally block to ensure cleanup")
print("4. When shutting down server")
print("\nClose examples:")
print("client_socket.close() # Close client connection")
print("server_socket.close() # Close server socket")
print("\nProper cleanup pattern:")
print("try:")
print(" # Socket operations here")
print(" client_socket.sendall(b'Hello')")
print(" data = client_socket.recv(1024)")
print("except Exception as e:")
print(" print(f'Error: {e}')")
print("finally:")
print(" client_socket.close() # Always close!")
print("\nUsing 'with' statement (recommended):")
print("with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:")
print(" s.connect(('localhost', 8080))")
print(" s.sendall(b'Hello')")
print(" data = s.recv(1024)")
print("# Socket automatically closed when leaving 'with' block")
# =============================================================================
# COMPLETE SOCKET EXAMPLES
# =============================================================================
print("\n--- Complete Socket Examples ---")
print("\n=== BASIC SERVER PATTERN ===")
print("""
import socket
# Create socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Bind to address
server_socket.bind(('localhost', 8080))
# Listen for connections
server_socket.listen(5)
print("Server listening on localhost:8080")
# Accept connection
client_socket, client_address = server_socket.accept()
print(f"Connected to {client_address}")
# Receive data
data = client_socket.recv(1024)
message = data.decode('utf-8')
print(f"Received: {message}")
# Send response
response = "Hello from server!"
client_socket.sendall(response.encode('utf-8'))
finally:
# Clean up
client_socket.close()
server_socket.close()
""")
print("\n=== BASIC CLIENT PATTERN ===")
print("""
import socket
# Create socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Connect to server
client_socket.connect(('localhost', 8080))
# Send data
message = "Hello from client!"
client_socket.sendall(message.encode('utf-8'))
# Receive response
data = client_socket.recv(1024)
response = data.decode('utf-8')
print(f"Server responded: {response}")
finally:
# Clean up
client_socket.close()
""")
# Close the example sockets we created
server_socket.close()
client_socket.close()
# =============================================================================
# DATETIME MODULE - WORKING WITH DATES AND TIMES
# =============================================================================
print("\n" + "="*60)
print("DATETIME MODULE - WORKING WITH DATES AND TIMES")
print("="*60)
print("--- Understanding the datetime Module ---")
print("The datetime module helps you work with dates and times.")
print("Main classes:")
print(" - datetime: Complete date and time")
print(" - date: Just the date (year, month, day)")
print(" - time: Just the time (hour, minute, second)")
print(" - timedelta: Difference between two times")
# =============================================================================
# UNDERSTANDING THE DATETIME DATA CLASS
# =============================================================================
print("\n--- Understanding the datetime Data Class ---")
print("The datetime class represents a specific moment in time")
print("It contains: year, month, day, hour, minute, second, microsecond")
# Creating datetime objects
print("\nCreating datetime objects:")
# Current date and time
now = dt.now()
print(f"Current date and time: {now}")
print(f"Type: {type(now)}")
# Specific date and time
specific_date = dt(2024, 12, 25, 14, 30, 0)
print(f"Christmas 2024 at 2:30 PM: {specific_date}")
# Today's date at midnight
today = dt.today()
print(f"Today at midnight: {today}")
# UTC time
utc_now = dt.utcnow()
print(f"Current UTC time: {utc_now}")
print("\nAccessing datetime components:")
print(f"Year: {now.year}")
print(f"Month: {now.month}")
print(f"Day: {now.day}")
print(f"Hour: {now.hour}")
print(f"Minute: {now.minute}")
print(f"Second: {now.second}")
print(f"Weekday: {now.weekday()} (0=Monday, 6=Sunday)")
print(f"Day name: {now.strftime('%A')}")
# =============================================================================
# CONVERTING STRING TO DATETIME (PARSING)
# =============================================================================
print("\n--- Converting String to datetime (Parsing) ---")
print("Use datetime.strptime(date_string, format) to parse strings")
print("'strptime' means 'string parse time'")
print("\nCommon format codes:")
print(" %Y - 4-digit year (2024)")
print(" %y - 2-digit year (24)")
print(" %m - Month as number (01-12)")
print(" %B - Full month name (January)")
print(" %b - Abbreviated month name (Jan)")
print(" %d - Day of month (01-31)")
print(" %H - Hour 24-hour format (00-23)")
print(" %I - Hour 12-hour format (01-12)")
print(" %M - Minute (00-59)")
print(" %S - Second (00-59)")
print(" %p - AM/PM")
print("\nString to datetime examples:")
# Various date string formats
date_strings = [
("2024-12-25", "%Y-%m-%d"),
("12/25/2024", "%m/%d/%Y"),
("25-Dec-2024", "%d-%b-%Y"),
("December 25, 2024", "%B %d, %Y"),
("2024-12-25 14:30:00", "%Y-%m-%d %H:%M:%S"),
("12/25/24 2:30 PM", "%m/%d/%y %I:%M %p"),
("Wed, 25 Dec 2024 14:30:00", "%a, %d %b %Y %H:%M:%S")
]
print("Parsing different date string formats:")
for date_str, format_str in date_strings:
try:
parsed_date = dt.strptime(date_str, format_str)
print(f" '{date_str}' -> {parsed_date}")
print(f" Format used: '{format_str}'")
except ValueError as e:
print(f" Error parsing '{date_str}': {e}")
print("\nCommon parsing patterns:")
print("# ISO format (most common)")
print("date = datetime.strptime('2024-12-25', '%Y-%m-%d')")
print("# US format")
print("date = datetime.strptime('12/25/2024', '%m/%d/%Y')")
print("# With time")
print("date = datetime.strptime('2024-12-25 14:30:00', '%Y-%m-%d %H:%M:%S')")
print("# 12-hour format with AM/PM")
print("date = datetime.strptime('12/25/2024 2:30 PM', '%m/%d/%Y %I:%M %p')")
# =============================================================================
# CONVERTING DATETIME TO STRING (FORMATTING)
# =============================================================================
print("\n--- Converting datetime to String (Formatting) ---")
print("Use datetime.strftime(format) to format datetime as string")
print("'strftime' means 'string format time'")
# Example datetime for formatting
example_date = dt(2024, 12, 25, 14, 30, 45)
print(f"\nExample datetime: {example_date}")
print("\nFormatting examples:")
formats = [
("%Y-%m-%d", "ISO date format"),
("%m/%d/%Y", "US date format"),
("%d/%m/%Y", "European date format"),
("%B %d, %Y", "Full month name"),
("%b %d, %Y", "Abbreviated month"),
("%A, %B %d, %Y", "Full day and month names"),
("%Y-%m-%d %H:%M:%S", "ISO datetime format"),
("%m/%d/%Y %I:%M %p", "US datetime with AM/PM"),
("%H:%M", "24-hour time only"),
("%I:%M %p", "12-hour time with AM/PM"),
("%Y-%m-%d %H:%M:%S.%f", "With microseconds"),
("%c", "Locale's date and time representation"),
("%x", "Locale's date representation"),
("%X", "Locale's time representation")
]
print("Different formatting options:")
for format_code, description in formats:
formatted = example_date.strftime(format_code)
print(f" {format_code:20} -> '{formatted}' ({description})")
print("\nPractical formatting examples:")
now = dt.now()
print(f"Current time in different formats:")
print(f" File timestamp: {now.strftime('%Y%m%d_%H%M%S')}")
print(f" Log format: {now.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" Human readable: {now.strftime('%A, %B %d, %Y at %I:%M %p')}")
print(f" ISO format: {now.strftime('%Y-%m-%dT%H:%M:%S')}")
# =============================================================================
# PRACTICAL DATETIME EXAMPLES
# =============================================================================
print("\n--- Practical datetime Examples ---")
print("\n=== PARSING USER INPUT ===")
def parse_user_date(date_input):
"""Try to parse a date string in multiple formats."""
formats = [
"%Y-%m-%d",
"%m/%d/%Y",
"%d/%m/%Y",
"%B %d, %Y",
"%b %d, %Y",
"%Y-%m-%d %H:%M:%S",
"%m/%d/%Y %I:%M %p"
]
for fmt in formats:
try:
return dt.strptime(date_input, fmt)
except ValueError:
continue
raise ValueError(f"Unable to parse date: {date_input}")
# Test the flexible parser
test_dates = [
"2024-12-25",
"12/25/2024",
"December 25, 2024",
"2024-12-25 14:30:00"
]
print("Flexible date parsing:")
for date_str in test_dates:
try:
parsed = parse_user_date(date_str)
print(f" '{date_str}' -> {parsed}")
except ValueError as e:
print(f" Error: {e}")
print("\n=== FORMATTING FOR DIFFERENT PURPOSES ===")
event_date = dt(2024, 7, 4, 18, 30, 0)
print(f"Event datetime: {event_date}")
print("Formatted for different purposes:")
print(f" Database: {event_date.strftime('%Y-%m-%d %H:%M:%S')}")
print(f" URL parameter: {event_date.strftime('%Y%m%d%H%M%S')}")
print(f" Email subject: {event_date.strftime('%B %d, %Y')}")
print(f" User display: {event_date.strftime('%A, %B %d at %I:%M %p')}")
print(f" Log file: {event_date.strftime('%Y-%m-%d %H:%M:%S')}")
print("\n=== WORKING WITH TIME ZONES ===")
print("Note: Basic datetime is 'naive' (no timezone info)")
print("For timezone-aware datetimes, use pytz or zoneinfo modules")
# Basic timezone simulation
import time
utc_now = dt.utcnow()
local_now = dt.now()
print(f"UTC time: {utc_now}")
print(f"Local time: {local_now}")
print(f"Difference: {local_now - utc_now}")
print("\n=== COMMON DATETIME PATTERNS ===")
# Age calculation
def calculate_age(birth_date_str):
"""Calculate age from birth date string."""
birth_date = dt.strptime(birth_date_str, "%Y-%m-%d")
today = dt.now()
age = today.year - birth_date.year
# Adjust if birthday hasn't occurred this year
if today.month < birth_date.month or (today.month == birth_date.month and today.day < birth_date.day):
age -= 1
return age
print("Age calculation:")
birth_date = "1990-06-15"
age = calculate_age(birth_date)
print(f" Born: {birth_date}")
print(f" Age: {age} years old")
# Time difference calculation
def time_until_event(event_date_str):
"""Calculate time until an event."""
event_date = dt.strptime(event_date_str, "%Y-%m-%d %H:%M:%S")
now = dt.now()
if event_date > now:
diff = event_date - now
days = diff.days
hours, remainder = divmod(diff.seconds, 3600)
minutes, _ = divmod(remainder, 60)
return f"{days} days, {hours} hours, {minutes} minutes"
else:
return "Event has already passed"
print("\nTime until event:")
future_event = "2024-12-31 23:59:59"
time_left = time_until_event(future_event)
print(f" Event: {future_event}")
print(f" Time remaining: {time_left}")
# =============================================================================
# SUMMARY AND BEST PRACTICES
# =============================================================================
print("\n" + "="*60)
print("SUMMARY AND BEST PRACTICES")
print("="*60)
print("=== SOCKET MODULE SUMMARY ===")
print("Key socket functions and their purposes:")
print(" socket.socket() - Create a new socket")
print(" socket.bind() - Assign address to socket")
print(" socket.listen() - Wait for connections")
print(" socket.accept() - Accept incoming connection")
print(" socket.send() - Send some data")
print(" socket.sendall() - Send all data")
print(" socket.recv() - Receive data")
print(" socket.close() - Close connection")
print("\nSocket best practices:")
print(" 1. Always close sockets when done")
print(" 2. Use try/finally or 'with' statements")
print(" 3. Handle connection errors gracefully")
print(" 4. Use sendall() instead of send()")
print(" 5. Remember to encode/decode strings to/from bytes")
print(" 6. Check if recv() returns empty bytes (connection closed)")
print("\n=== DATETIME MODULE SUMMARY ===")
print("Key datetime operations:")
print(" datetime.now() - Get current date/time")
print(" datetime.strptime() - Parse string to datetime")
print(" datetime.strftime() - Format datetime to string")
print(" datetime() - Create specific datetime")
print("\nDatetime best practices:")
print(" 1. Use consistent date formats in your application")
print(" 2. Handle parsing errors with try/except")
print(" 3. Consider timezone issues for global applications")
print(" 4. Use ISO format (YYYY-MM-DD) for storage")
print(" 5. Format dates appropriately for user display")
print(" 6. Remember strptime() for parsing, strftime() for formatting")
print("\nCommon format codes to remember:")
print(" %Y - 4-digit year %m - Month (01-12) %d - Day (01-31)")
print(" %H - Hour (00-23) %M - Minute (00-59) %S - Second (00-59)")
print(" %B - Full month %b - Short month %A - Full weekday")
print("\n=== GETTING HELP ===")
print("Remember to use help() when you need more information:")
print(" help(socket) - Socket module overview")
print(" help(socket.socket) - Socket class details")
print(" help(datetime) - Datetime module overview")
print(" help(datetime.datetime) - Datetime class details")
print(" help(datetime.datetime.strftime) - Formatting help")
print(" help(datetime.datetime.strptime) - Parsing help")
print("\nYou're now ready to work with sockets and dates in Python!")
print("Practice with small examples and gradually build more complex programs.")