Online-Academy
Look, Read, Understand, Apply

Questions_07-26

  • What is slicing? Write code to display a string in reverse.
  • How do you define a function in Python? Write a function that returns the square of a given number.
  • What is the purpose of self in Python class methods? Create a class Person with methods to set and display its attributes. Assume suitable attributes such as id, name, age, and gender.
  • What is list comprehension? Write a code to square number of a list.
  • How do you import a module in Python? Explain with an example.
  • What is lambda function? Provide example.
  • Using MySQL, write Python code to insert one record into the Person table of database College.db.
  • What is dataframe? Write a code to show descriptive statistics of numeric attributes of dataframe you created.
  • Write code to plot scatter plot using data of your own choice.
  • Write a Python program to count the frequency of each word in a sentence using a dictionary.
  • Create a NumPy array and find its mean, maximum, and minimum values.
  • Write a Python program to write five names into a text file and then read and display the contents.
  • Write a Python program to divide two numbers using exception handling.
  • Using list comprehension, create a list containing only even numbers from 1 to 20.