python_Viva_que_sw read
python_Viva_que_sw read
page,
© Copyright by Interviewbit
oC e
What are lists and tuples? What is the key difference between the two?
What are the common built-in data types in Python?
SF
89. Write a Program to match a string that has the letter ‘a’ followed by 4 to 8 'b’s.
90. Write a Program to convert date from yyyy-mm-dd format to dd-mm-yyyy
format.
91. Write a Program to combine two different dictionaries. While combining, if you
find the same keys, you can add the values of these same keys. Output the new
dictionary
92. How will you access the dataset of a publicly shared spreadsheet in CSV format
stored in Google Drive?
Introduction to Python:
Python was developed by Guido van Rossum and was released first on February 20,
1991. It is one of the most widely-used and loved programming languages and is
interpreted in nature thereby providing flexibility of incorporating dynamic
semantics. It is also a free and open-source language with very simple and clean
syntax. This makes it developers easy to learn python. Python also supports object-
oriented programming and is most commonly used to perform general-purpose
programming. Due to its simplistic nature and the ability to achieve multiple
functionalities in fewer lines of code, python’s popularity is growing tremendously.
Python is also used in Machine Learning, Artificial Intelligence, Web Development,
Web Scraping, and various other domains due to its ability to support powerful
computations using powerful libraries. Due to this, there is a huge demand for
python developers in India and across the world. Companies are willing to offer
amazing perks.and benefits to these developers. In this article, we will see the most
commonly asked python interview questions and answers which will help you excel
and bag amazing job offers.
We have classified them into the following sections:
Bb, InterviewBit
e Alocal scope refers to the local objects available in the current function.
e A global scope refers to the objects available throughout the code execution
since their inception.
e A module-level scope refers to the global objects of the current module
accessible in the program.
e An outermost scope refers to all the built-in names callable in the program. The
objects in this scope are searched last to find the name referenced.
Note: Local scope objects can be synced with global scope objects using keywords
such as global.
7. What are lists and tuples? What is the key difference between
the two?
Lists and Tuples are both sequence data types that can store a collection of objects
in Python. The objects stored in both sequences can have different data types. Lists
are represented with square brackets ['sara', 6, 9.19] , while tuples are
represented with parantheses ('ansh', 5, 0.97)
But what is the real difference between the two? The key difference between the two
is that while lists are mutable, tuples on the other hand are immutable objects.
This means that lists can be modified, appended or sliced on the go but tuples
remain constant and cannot be modified in any manner. You can run the following
example on Python IDLE to confirm the difference:
e None Type:
None keyword represents the null values in Python. Boolean equality
operation can be performed using these NoneType objects.
e Numeric Types:
There are three distinct numeric types - integers, floating-point numbers, and
complex numbers. Additionally, booleans are a sub-type of integers.
Note: The standard library also includes fractions to store rational numbers and
decimal to store floating-point numbers with user-defined precision.
e Sequence Types:
According to Python Docs, there are three basic Sequence Types - lists, tuples,
and range objects. Sequence typeshavethe in and not in operators
defined for their traversing their elements. These operators share the same
priority as the comparison operations.