Page 429 - ComputerScience_Class_11
P. 429

Program 5: To demonstrate the use of punctuators (separators) in Python.
                     Program 5.py

                  File  Edit  Format   Run    Options  Window     Help

                     # 1. Parentheses ( ) - used in function calls and expressions
                     print("Demonstrating Parentheses")


                     # 2. Square Brackets [ ] - used in lists
                     numbers = [1, 2, 3, 4]
                     print("List:", numbers)


                     # 3. Curly Braces { } - used in dictionaries
                     student = {"name": "Rahul", "marks": 85}
                     print("Dictionary:", student)

                     # 4. Comma (,) - used to separate values
                     a, b, c = 10, 20, 30
                     print("Values:", a, b, c)


                     # 5. Colon (:) - used in function and control statements
                     def greet(name):
                         print("Hello,", name)


                     greet("Aman")


                     # 6. Dot (.) - used to access methods
                     text = "python"
                     print("Uppercase:", text.upper())


                     # 7. Quotation Marks (' ' or " ") - used for strings
                     message = "Welcome to Python"
                     print("Message:", message)




                     Output

                    Demonstrating Parentheses
                    List: [1, 2, 3, 4]
                    Dictionary: {'name': 'Rahul', 'marks': 85}
                    Values: 10 20 30
                    Hello, Aman
                    Uppercase: PYTHON
                    Message: Welcome to Python










                                                               Installation & IDE and Fundamentals of Python Programming  427
   424   425   426   427   428   429   430   431   432   433   434