We appreciate your visit to 1 What will be the output of print Welcome To My Blog 2 6 Welcome To My Blog 5 9 2 What will be the. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!

1. What will be the output of `print("Welcome To My Blog"[2:6] + "Welcome To My Blog"[5:9])`?

2. What will be the output of `print(10 > 20)`?

3. Write the steps to perform an Insert query in a database connectivity application. The table 'student' has columns: rollno, name, age. Example values: (1, 'AMIT', 22).

4. What will be the output of `print([x + y for x in 'ball' for y in 'boy'])`?

5. What will be the output of the following code?
```python
d = {1:100, 2:200}
for x, y in d.items():
print(x * y, end="#")
```

6. What will be the output of the following code?
```python
l = [1, 2, 5, 6, 7, 9, 10, 22, 38]
k = [el * r for el in l if (el - 4) > 1 for r in l[:4]]
print(k)
```

7. Given the list `L = [1, 3, 6, 82, 5, 7, 11, 92]`, what is the output of `print(L[2:5])`?

8. What will be the output of the following code?
```python
marks = {"Ashok": 98.6, "Ramesh": 95.5}
print(list(marks))
```

9. What will be the output of `print(75.0 / 4 + (2 ** 3))`?

10. What will be the output of the following code?
```python
L = [4, 3, 6, 8, 2]
Lst = []
for i in range(len(L)):
if L[i] % 2 == 0:
t = (L[i], L[i] ** 2)
Lst.append(t)
print(Lst)
```

11. What will be the output of the following code?
```python
a = [0, 1, 2, 3]
del a[:]
print(a)
```

12. What will be the output of the following code?
```python
a = [1, 2, 3, 4]
b = [sum(a[0:x + 1]) for x in range(len(a))]
print(b)
```

13. What will be the output of the following code?
```python
data = [1, 2, 4, 5]
for x in data:
x = x + 10
print(data)
```

14. What will be the output of the following code?
```python
a = [1, 2, 3, 4, 5]
for i in range(1, 5):
a[i - 1] = a[i]
for i in range(0, 5):
print(a[i], end=" ")
```

15. What will be the output of the following code?
```python
l = [1, 2, 3, 4, 5]
l[1:2] = [7, 8]
print(l)
```

16. Given `tp = (1, 2, 3, 4, 5, 6)`, which of the following two statements will give the same output?
1. `print(tp[:-1])`
2. `print(tp[0:5])`
3. `print(tp[0:4])`
4. `print(tp[-4:])`

17. Given `tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)`, what will be the output of `print(tup1[3:7:2])`?

Answer :

Let's go through each part of the question step by step:

  1. Output of: print("Welcome To My Blog"[2:6] + "Welcome To My Blog"[5:9])

    • The first slice, [2:6], extracts from the string starting at index 2 up to, but not including, index 6. This results in "lcom".
    • The second slice, [5:9], extracts from index 5 up to, but not including, index 9, which is "me T".
    • Concatenating these two results in "lcomme T".
  2. Output of: print (10>20)

    • This statement checks if 10 is greater than 20, which is false. Therefore, it outputs False.
  3. Steps to perform an Insert query in a database connectivity application for the 'student' table with values (1, 'AMIT', 22):

    • Step 1: Establish a connection to the database using a connection string or credentials.
    • Step 2: Create a cursor object using the established connection. This object will allow you to execute SQL queries.
    • Step 3: Write the SQL Insert Query: INSERT INTO student (rollno, name, age) VALUES (1, 'AMIT', 22).
    • Step 4: Execute the query using the cursor object.
    • Step 5: Commit the transaction to make sure changes are saved to the database.
    • Step 6: Close the cursor and database connection to free up resources.
  4. Output of: print([x+y for x in 'ball' for y in 'boy'])

    • This uses a list comprehension to create combinations of each character from 'ball' with each character from 'boy'. The resulting list is ['bb', 'bo', 'by', 'ab', 'ao', 'ay', 'lb', 'lo', 'ly', 'lb', 'lo', 'ly'].
  5. Output of:

    d = {1:100, 2:200}
    for x,y in d:
    print(x*y, end="#")
    • This code will raise an error because iterating over a dictionary directly returns keys. The correct way would be for x, y in d.items():, which would print 100#400#.
  6. Output of:

    l = [1,2,5,6,7,9,10,22,38]
    k = [el*r for el in l if (el-4)>1 for r in l[:4]]
    print(k)
    • For elements where (el-4)>1 is true, multiply with each element in l[:4]. The result is [10, 20, 50, 60, 12, 24, 60, 72, 84, 168, 210, 252, 30, 60, 150, 180].
  7. Output of: print(L[2:5]) given L=[1,3,6,82,5,7,11,92]

    • Slices from index 2 to 4, resulting in [6, 82, 5].
  8. Output of:

    marks = {"Ashok":98.6, "Ramesh":95.5}
    print(list(()))
    • This will simply print an empty list [] as list(()) converts an empty tuple to a list.
  9. Output of: print(75.0/4 + (2**3))

    • Carry out the calculation: [tex]\frac{75.0}{4} = 18.75[/tex] and [tex](2^3) = 8[/tex]; thus, the result is [tex]18.75 + 8 = 26.75[/tex].
  10. Output of:

    L=[4,3,6,8,2]
    Lst=[]
    for i in range(len(L)):
    if L[i]%2==0:
    t=(L[i],L[i]**2)
    Lst.append(t)
    print(Lst)
    • Identifies even numbers and adds a tuple with their square: [(4, 16), (6, 36), (8, 64), (2, 4)].
  11. Output of:

    a = [0, 1, 2, 3]
    del a[:]
    print(a)
    • Deletes all items in the list, resulting in an empty list [].
  12. Output of:

    a=[1,2,3,4]
    b=[sum(a[0:x+1]) for x in range(0,len(a))]
    print (b)
    • Computes cumulative sums: [1, 3, 6, 10].
  13. Output of:

    data = [1,2,4,5]
    for x in data:
    x = x + 10
    print(data)
    • The list remains unchanged as data = [1, 2, 4, 5] because changes to x don't affect the list.
  14. Output of:

    a=[1,2,3,4,5]
    for i in range(1,5):
    a[i-1]=a[i]
    for i in range(0,5):
    print(a[i],end=" ")
    • Shifts elements left, filling with the last value: 2 3 4 5 5 .
  15. Output of:

    l=[1,2,3,4,5]
    l[1:2]=[7,8]
    print(l)
    • Replaces the element at index 1 with list [7,8], yielding [1, 7, 8, 3, 4, 5].
  16. Given: tp = (1,2,3,4,5,6), Which statements give the same output?

    • print(tp[:-1]) and print(tp[0:5]) both give (1, 2, 3, 4, 5). So, options 1 and 2 are correct.
  17. Output of: print(tup1[3:7:2]) given tup1=(10,20,30,40,50,60,70,80,90)

    • Slicing from index 3 to 6 with a step of 2 results in (40, 60).

Thanks for taking the time to read 1 What will be the output of print Welcome To My Blog 2 6 Welcome To My Blog 5 9 2 What will be the. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!

Rewritten by : Barada