Loading...
Follow Us:

Computer Science

Computer Science

1. What is a variable in Python?

  A variable is a container for storing data values.

2. How do you declare a variable in Python?

Variables are declared by assigning a value to them without specifying the type: x = 3

3. What are the basic data types in Python?

The basic data types in Python include int, float, str, bool, and complex.

4. How do you take user input in Python?

The input() function is used to take user input in string format.

5.What is a list in Python?

A list is an ordered, mutable collection of elements, defined using square brackets [].

6. How do you append an element to a list in Python?

Use the append() method.

7 .What is the difference between remove() and pop() in lists?

remove() deletes a specific element by value, while pop() removes an element by index.

8.What is a tuple in Python?

A tuple is an ordered, immutable collection of elements, defined using parentheses ().

9.How is a dictionary different from a list in Python?

A dictionary stores key-value pairs, whereas a list stores individual elements indexed by their position.

10.How do you access a value from a dictionary in Python?

You access a value using its key. Example: my_dict['name'].

11.What is a function in Python?

A function is a reusable block of code that performs a specific task, defined using the def keyword.

12.What are positional arguments in Python functions?

Positional arguments are passed to functions in the order in which they are defined.

13.What is a keyword argument in Python functions?

A keyword argument is passed using the argument name and value.

14.How do you handle exceptions in Python?

Exceptions are handled using the try-except block.

15.What is the use of the finally block in exception handling?

The finally block is executed regardless of whether an exception occurred, often used for cleanup actions.

16.How do you read a text file in Python?

Use the open() function, followed by read() or readlines() 

17.How do you write to a file in Python?

Use the open() function in write mode ('w'), followed by write() method

18 What is the difference between w and a mode when opening a file?

w mode overwrites the file, while a mode appends to the file without overwriting.

19. What is the purpose of the with statement in file handling?

 The with statement ensures proper file closure after operations, even if exceptions occur.

20.What are modules in Python?

Modules are files containing Python code (functions, variables) that can be imported and reused in other scripts.

21.How do you import a module in Python?

Use the import keyword. Example: import math.

22. What is the difference between import and from import?

import imports the entire module, while from imports specific functions or variables from a module. Example: from math import sqrt.

23.What is MySQL?

 MySQL is a relational database management system (RDBMS) that uses Structured Query Language (SQL).

24.What is a primary key in MySQL?

A primary key is a unique identifier for records in a database table, ensuring no duplicates.

25.How do you create a table in MySQL?

A table is created using the CREATE TABLE statement. Example: CREATE TABLE students (id INT, name VARCHAR(100));.

26. What is the use of the SELECT statement in MySQL?

The SELECT statement retrieves data from a database.

27. What is the purpose of the WHERE clause in MySQL?

The WHERE clause is used to filter records based on a specified condition.

28. How do you update records in a MySQL table?

The UPDATE statement is used to modify existing records.

29. What does the JOIN clause do in MySQL?

JOIN combines rows from two or more tables based on a related column.

30 What is the use of ORDER BY in MySQL?

ORDER BY sorts the result set in ascending or descending order.

31.How do you delete a record from a table in MySQL?

Use the DELETE FROM statement.

32. How do you count the number of rows in a table in MySQL?

Use the COUNT() function. Example: SELECT COUNT(*) FROM students;.

33. What is GROUP BY in MySQL?

GROUP BY groups rows that have the same values into summary rows, often used with aggregate functions.

34.How do you add a new column to an existing table in MySQL?

Use the ALTER TABLE statement..

35: How can you delete a table in MySQL?

Use the DROP TABLE statement.

36: What is a computer network?

A computer network is a group of interconnected devices that communicate with each other to share resources.

37: What is the full form of TCP/IP?

Transmission Control Protocol/Internet Protocol.

38: What is an IP address?

An IP address is a unique numerical identifier assigned to each device on a network.

39 What is a MAC address?

A MAC address is a hardware identifier assigned to a network interface card (NIC), used for communication within a network segment.

40 What is a LAN?

A Local Area Network (LAN) is a network that connects devices within a limited geographical area, such as a home or office.

41 What is the purpose of a router?

A router directs data packets between networks, determining the best path for data to travel.

42 What is the difference between HTTP and HTTPS?

HTTP is unsecured, while HTTPS is the secure version, using encryption (SSL/TLS) to protect data.

43 What is the role of a firewall in networking?

A firewall monitors and controls incoming and outgoing network traffic based on security rules.

44.What is a protocol in networking?

A protocol is a set of rules governing data communication between devices in a network.

45.What is the difference between a hub and a switch?

A hub broadcasts data to all devices on a network, while a switch sends data only to the intended recipient.

46.What is FTP used for?

File Transfer Protocol (FTP) is used for transferring files between a client and a server on a network.

47: What is Wi-Fi?

Wi-Fi is a wireless technology that allows devices to connect to a network and access the internet using radio waves.

48: What is the full form of SMTP?

Simple Mail Transfer Protocol, used for sending emails.

WhatsApp
Enquiry