Page 253 - COPA Vol II of II - TP - Bengali
P. 253

String1 = “{1} {0} {2}”.format(‘Welcome’, ‘to’, ‘NIMI’)  print(String1)
            print(“\nPrint String in Positional order: “)         Output:
            print(String1)                                        Print String in default order:
            # Keyword Formatting                                  Welcome to NIMI
            String1  =  “{l}  {f}  {g}”.format(g=’NIMI’,  f=’to’,  l=’Wel-  Print String in Positional order:
            come’)                                                to Welcome NIMI
            print(“\nPrint String in order of Keywords: “)        Print String in order of Keywords:
                                                                  Welcome to NIMI


            টযাস্ক 3 : িযানরখ অপযানরশন
            Example1:                                             print(x.strftime(“%A”))
            import datetime                                       Output:
            x = datetime.datetime.now()                           2022
            print(x)                                              Saturday
            Output:                                               Example3:
            2022-07-09 16:05:52.588848                            import datetime
            Example 2:                                            x = datetime.datetime(2020, 5, 17)
            import datetime                                       print(x)
            x = datetime.datetime.now()                           Output:
            print(x.year)                                         2020-05-17 00:00:00



            টযাস্ক 4 : ইনপুি এেং আউিপুি
            Example for Input:                                    print()
            x = int (input(“Enter Number 1: “))                   # taking three inputs at a time
            y = int (input(“Enter Number 2: “))                   x, y, z = input(“Enter three values: “).split()
            print (“The sum = “, x+y)                             print(“Total number of students: “, x)
            Output:                                               print(“Number of boys is : “, y)
            Enter Number 1: 5                                     print(“Number of girls is : “, z)
            Enter Number 2: 10                                    print()
            The sum = 15                                          # taking two inputs at a time
            Example for Output:                                   a, b = input(“Enter two values: “).split()
            print (“Welcome to Python Programming”)               print(“First number is {} and second number is {}”.
            x = 5                                                 format(a, b))
            y = 6                                                 print()
            z = x + y                                             # taking multiple inputs at a time
            print (z)                                             # and type casting using list() function
            print (“The sum = “, z)                               x = list(map(int, input(“Enter multiple values: “).split()))
            print (“The sum of “, x, “ and “, y, “ is “, z)       print(“List of students: “, x)
            Output:                                               output:
            Welcome to Python Programming                         Enter two values: 10 15
            11                                                    Number of boys: 10
            The sum = 11                                          Number of girls: 15
            The sum of 5 and 6 is 11                              Enter three values: 10 15 20
            Example for Input and Output:                         Total number of students: 10
            # Python program showing how to multiple input and    Number of boys is : 15
            output using split                                    Number of girls is : 20
            # taking two inputs at a time                         Enter two values: 10 15
            x, y = input(“Enter two values: “).split()            First number is 10 and second number is 15
            print(“Number of boys: “, x)                          Enter multiple values: 10 15 12 13 15
            print(“Number of girls: “, y)                         List of students: [10, 15, 12, 13, 15]



                                   IT & ITES - COPA - (NSQF প্ললভল - 2022) - অনুশীলনী 1.39.04                  239
   248   249   250   251   252   253   254   255   256   257   258