Tuples in Python

Tuple

Tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The main difference between the tuples and the lists is that the tuples cannot be changed unlike lists. Tuples use parentheses whereas lists use square brackets.

Creating atuple is as simple as puttingdifferent comma-separated values. Optionally, you can put these comma-separated values between parentheses. For eg,

tup1 = (‘physics’, ‘chemistry’, 1997, 2000)

tup2 = (1, 2, 3, 4, 5)

tup3 = “a”, “b”, “c”, “d”

The empty tuple is written as two parentheses containing nothing. tup1 = ();

To create a tuple containing a single value, we have to include a comma even though there is only one value.

tup1 = (50,)

Like string indices, tuple indices start at 0 and they can be sliced and concatenated

Accessing values in Tuples:

tup1 = (‘physics’, ‘chemistry’, 1997, 2000)

tup2 = (1, 2, 3, 4, 5, 6, 7 )

print (“tup1[0]: “, tup1[0])

print (“tup2[1:5]: “, tup2[1:5])

To access values in tuple, use the square brackets for slicing along with the index or indices to obtain the value available at that index. For eg,

When the above code is executed, it produces the following result, tup1[0] : physics

tup2[1:5] : [2, 3, 4, 5]

Tuple Assignment :

>>> a, b = 3, 4

>>> print a 3

>>> print b 4

>>> a, b, c = (1,2,3), 5, 6

>>> print a (1, 2, 3)

>>> print b 5

>>> print c 6

Once in a while, it is useful to perform multiple assignments in a single statement and this can be done with tuple assignment:

>>> a, b, c, d = 1, 2, 3

ValueError: need more than 3 values to unpack

The left side is a tuple of variables; the right side is a tuple of values. Each value is assigned to its respective variable. All the expressions on the right side are evaluated before any of the assignments.

The number of variables on the left and the number of values on the right have to be the same:

Such statements can be useful shorthand for multiple assignment statements, but care should be taken that it does not make the code more difficult to read.

One example of tuple assignment that improves readability is when we want to swap the values of two variables. With conventional assignment statements, we have to use a temporary variable. For example, to swap a and b:

temp = a a = b

b = temp

If we have to do this often, such an approach becomes cumbersome. Python provides a form of tuple assignment that solves this problem neatly:

Tuples as return values :

def swap(x, y):

return y, x

Functions can return tuples as return values. For example, we could write a function that swaps two parameters:

Then we can assign the return value to a tuple with two variables:

a, b = swap(a, b)

def swap(x, y):

x, y = y, x

In this case, there is no great advantage in making swap a function. In fact, there is a danger in trying to encapsulate swap, which is the following tempting mistake:

If we call swap like this swap(a, b)

then a and x are aliases for the same value. Changing x inside swap makes x refer to a different value, but it has no effect on a in main. Similarly, changing y has no effect on b. This function runs without producing an error message, but it doesn’t do what we intended. This is an example of a semantic error.

Basic tuples operations, Concatenation, Repetition, in Operator, Iteration :

Tuples respond to the + and * operators much like strings; they mean concatenation and repetition here too, except that the result is a new tuple, not a string.

In fact, tuples respond to all of the general sequence operations we used on strings in the previous chapter.

Python Expression Results Description
len((1, 2, 3)) 3 Length
(1, 2, 3) + (4, 5, 6) (1, 2, 3, 4, 5, 6) Concatenation
(‘Hi!’,) * 4 (‘Hi!’, ‘Hi!’, ‘Hi!’, ‘Hi!’) Repetition
3 in (1, 2, 3) True Membership
for x in (1,2,3) : print (x, end=’ ‘) 1 2 3 Iteration

Built-in Tuple Functions :

SN Function with Description
1 cmp(tuple1, tuple2)   No longer available in Python 3.
2 len(tuple)   Gives the total length of the tuple.
3 max(tuple)   Returns item from the tuple with max value.
4 min(tuple)   Returns item from the tuple with min value.
5 tuple(seq)   Converts a list into tuple.

Python includes the following tuple functions-

Tuplelen()MethodDescription

The len() method returns the number of elements in the tuple.

Syntax

Following is the syntax for len() method- len(tuple)

Parameters

tuple – This is a tuple for which number of elements to be counted.

Return Value

This method returns the number of elements in the tuple.

Example

The following example shows the usage of len() method. tuple1, tuple2 = (123, ‘xyz’, ‘zara’), (456, ‘abc’)

print (“First tuple length : “, len(tuple1)) print (“Second tuple length : “, len(tuple2)) First tuple length : 3 Second tuple length : 2

When we run above program, it produces following result-

Tuple max() Method

Description

The max() method returns the elements from the tuple with maximum value.

Syntax

Following is the syntax for max() method- max(tuple)

Parameters

tuple – This is a tuple from which max valued element to be returned.

Return Value

This method returns the elements from the tuple with maximum value.

Example

tuple1, tuple2 = (‘maths’, ‘che’, ‘phy’, ‘bio’), (456, 700, 200) print (“Max value element : “, max(tuple1))

print (“Max value element : “, max(tuple2))

The following example shows the usage of max() method. Max value element : phy Max value element : 700

Tuple min() Method

Description

The min() method returns the elements from the tuple with minimum value.

Syntax

Following is the syntax for min() method- min(tuple)

Parameters

tuple – This is a tuple from which min valued element is to be returned.

Return Value

This method returns the elements from the tuple with minimum value.

Example

tuple1, tuple2 = (‘maths’, ‘che’, ‘phy’, ‘bio’), (456, 700, 200) print (“min value element : “, min(tuple1))

print (“min value element : “, min(tuple2))

The following example shows the usage of min() method.

When we run the above program, it produces the following result- min value element : bio min value element : 200

Tuple tuple() Method Description

The tuple() method converts a list of items into tuples.

Syntax

Following is the syntax for tuple() method- tuple( seq )

Parameters

seq – This is a tuple to be converted into tuple.

Return Value

This method returns the tuple.

Example

The following example shows the usage of tuple() method. list1= [‘maths’, ‘chemistry’, ‘phy’, ‘bio’] tuple1=tuple(list1) print (“tuple elements : “, tuple1)

tuple elements : (‘maths’, ‘chemistry’, ‘phy’,’bio’)

When we run the above program, it produces the following result

Please follow and like us:
0

DevOps Practice Tool

DevOps Tools

To expedite and actualize DevOps process apart from culturally accepting it, one also needs various DevOps tools like Puppet, Jenkins, GIT, Chef, Docker, Selenium, Azure/AWS etc to achieve automation at various stages which helps in achieving Continuous Development, Continuous Integration, Continuous Testing, Continuous Deployment, Continuous Monitoring to deliver a quality software to the customer at a very fast pace.

Tools Required for

  • Version Control System
  • Configuration management
  • Ticketing System
  • Resource Monitoring
  • Provisioning

What is CI and CD

  • Continuous integration is a software development practice where developers regularly merge their code changes into a central repository, after which automated builds and tests are run. The key goals of continuous integration are to find and address bugs quicker, improve software quality, and reduce the time it takes to validate and release new software updates.
  • Continuous delivery is a software development practice where code changes are automatically built, tested, and prepared for a release to production. It expands upon continuous integration by deploying all code changes to a testing environment and/or a production environment after the build stage. When continuous delivery is implemented properly, developers will always have a deployment-ready build artifact that has passed through a standardized test process.

CI and CD enables agile teams to increase deployment frequency and decrease lead time for change, change-failure rate, and mean time to recovery key performance indicators (KPIs), thereby improving quality and delivering value faster. The only prerequisites are a solid development process, a mindset for quality and accountability for features from ideation to deprecation, and a comprehensive pipeline.

DevOps as a profession – DevOps Engineer

When the company’s management decides to shift to DevOps, the need arises to train IT department specialists to master certain practices and use new tools. In this case, either developers or system administrators need to assume new job responsibilities. A better alternative may be hiring a professional with a clear understanding of the DevOps approach and an ability to set all the necessary processes properly.

After getting software requirements specifications, a DevOps engineer starts setting up the IT infrastructure required for the development. When the IT infrastructure is ready and provided to developers, testers, and other specialists involved in the development cycle, a DevOps engineer ensures that the development and testing environments are aligned with the production environment.

If you ask the DevOps engineer what exactly they do, the answer will likely mention “automation”. What they actually mean is the following:

  • Automating software delivery from the testing environment to the production.
  • Managing physical and virtual servers and their configurations.
  • Monitoring the IT infrastructure’s state and the application’s behavior.

Things to know to become a DevOps engineer

1.Linux and/or Windows Administrator
2.Programming Skills
3.Cloud Management Skills
4.Practical Experience with Containers and orchestration

Below is a more comprehensive list of tools most commonly required to get a job in DevOps:

  • Version control systems (Git, Team Foundation Server (TFS), Apache Subversion, etc.).
  • Continuous integration tools (Jenkins, Travis CI, TeamCity, and others). ·Software deployment automation platforms (Chef, Puppet, Ansible, etc.).
  • Systems monitoring tools (Grafana, Zabbix, Prometheus, and the like).
  • Cloud infrastructure (AWS, Microsoft Azure, Google Cloud Platform (GCP), Alibaba Cloud, and more).
  • Container orchestration tools (such as Kubernetes, Docker Swarm, Apache Mesos, OpenShift, Google Kubernetes Engine (GKE), Azure Kubernetes Service (AKS), WS EKS)

DevOps engineers’ average salary in the US is twice as high as that of a system administrator. The reason is quite simple —a competent DevOps engineer can greatly increase the efficiency of software development and operations.
More: https://www.scnsoft.com/blog/how-to-become-a-devops-engineer

Azure DevOps Features
You can use one or more of the following features based on your business needs:
1.Azure Boards delivers a suite of Agile tools to support planning and tracking work, code defects, and issues using Kanban and Scrum methods.
2.Azure Repos provides Git repositories or Team Foundation Version Control (TFVC) for source control of your code.
3.Azure Pipelines provides build and release services to support continuous integration and delivery of your apps.
4.Azure Test Plans provides several tools to test your apps, including manual/exploratory testing and continuous testing.
5.Azure Artifacts allows teams to share Maven, npm, and NuGet packages from public and private sources and integrate package sharing into your CI/CD pipeines.

Azure DevOps supports adding extensions and integrating with other popular services, such as: Campfire, Slack, Trello, UserVoice, and more, and developing your own custom extensions. Azure DevOps provides extensive integration with industry and community tools. It is far from the closed-off single vendor solution that was the early version of TFS. As noted above, there is a market place which makes hundreds of extensions available, so if Azure Develops doesn’t do something out of the box, odds are a tool exists in the market which does.

Pricing:
https://azure.microsoft.com/en-in/pricing/details/devops/azure-devops-services/

To Create an DevOps Account / Organization:
Sign up with a personal Microsoft account
1.Visit https://azure.microsoft.com/services/devops/
2.Click Start free
3.Either Login with Existing Microsoft Account or Create a New one.
An organization is created based on the account you used to sign in. Sign in to your organization at any time,
(https://dev.azure.com/{yourorganization}).

Create a Project to get started

  • If you signed up for Azure DevOps with a newly created Microsoft account (MSA), your project is automatically created and named based on your sign-in.
  • If you signed up for Azure DevOps with an existing MSA or GitHub identity, you’re automatically prompted to create a project. You can create either a public or private project.
  • A public Git Hub repository is accessible to everyone, whereas a private repositoryis accessible to you and the people you share it with. In both cases, only collaborators can commit changes to a GitHub repository.

Create Users
1.Create an outlook ID
2.Activate your Subscription (FREE account or Azure Pass Sponsorship or get owner rights other users subscription)
3.Visit https://portal.office.com
4.Go to Azure Active Directory and create users user1@orgname.onmicrosoft.comand user2@orgname.onmicrosoft.com

Invite team members
1.Create couple of outlook ids
2.Use primary email id and visit https://dev.azure.com/.
3.Start Free
4.Create a project to get started
 a. Project Name = “Demo Project”
 b. Description = “For Demo”
 c. Visibility = “Private”
 d. Expand Advanced, Version Control = Git, Work Item process = “Agile”
 e. Create Project
5.Invite Users
 a. Use bread crump and navigate to Organization
 b. Select Organization settings.
 c. Select UsersàAdd new users.
 d. Users = <Email Id of another User), Access level = Basic, Add to project = <project created before>, Azure DevOps Group=Project Contributors
Note: Youwill have to now login as another use and accept the invitation. Do the same in different browser..

Start to Learn Complete Azure DevOps Online

Please follow and like us:
0

What is Azure DevOps?

Azure DevOps Introduction

Azure DevOps (formerly Visual Studio Team Services) is a hosted suite of service providing development and collaboration tools for anyone who wants an enterprise-grade DevOps tool chain. Azure DevOps can help your team release code in a more efficient, cooperative, and stable manner. Azure DevOps has a lot of inbuilt functionality that allows teams to get up and running with managing their project and automating their workflows to increase productivity with a very short initial learning curve.

you can quickly get up and running with the many tools available.

  • Git repositories for source control
  • Build and Release pipelines for CI/CD automation
  • Agile tools covering Kanban/scrum project methodologies
  • Many pre-built deployment tasks/steps to cover the most common use cases and the ability to extend this with your own tasks.
  • Hosted build/release agents with ability to additionally run your own
  • Custom dashboards to report on build/release and agile metrics.
  • Built in wiki

Azure DevOps is available in two different forms:

  • Azure DevOps Server, collaboration software for software development formerly known as Team Foundation Server (TFS) and Visual Studio Team System (VSTS)
  • Azure DevOps Services, cloud service for software development formerly known as Visual Studio Team Services and Visual Studio Online

History: This first version of Team Foundation Server was released March 17, 2006.

Product name Form Release year
Visual Studio 2005 Team System On-premises 2006
Visual Studio Team System 2008 On-premises 2008
Team Foundation Server 2010 On-premises 2010
Team Foundation Service Preview Cloud 2012
Team Foundation Server 2012 On-premises 2012
Visual Studio Online Cloud 2013
Team Foundation Server 2013 On-premises 2013
Team Foundation Server 2015 On-premises 2015
Visual Studio Team Services Cloud 2015
Team Foundation Server 2017 On-premises 2017
Team Foundation Server 2018 On-premises 2017
Azure DevOps Services Cloud 2018
Azure DevOps Server 2019 On-premises 2019

Traditional Software Development Life Cycle

The developers create applications and the operations teams deploy them to an infrastructure they manage.

Responsibility of Developers.

1.Develop Software Applications
2.New Features Implementation
3.Collaborate with other Developers in Team.
4.Maintain Source Repos and deal with versions.
5.Pass on the code to the operations team.

Responsibility of IT Operations

1.IT Operations determine how the software and hardware are managed.
2.Plan and Provide the required IT Infrastructure for Testing and Production of Applications.
3.Deploy the Application and Database.
4.Validate and Monitor performance.

Waterfall Model:

In the below diagram you will see the phases it will involve:

How the traditional Systems worked:

Tasks would be divided into different groups based on specialization

1.Group to write specification
2.Group that Develop application.
3.Group that Test the application.
4.Group to configure and manage VM
5.Group to that hands over VM to another group to install database
6.and so on…

A system / process is created for each action and each group operations in isolation from others. Groups communicate with each other in a very formal way, such as using ticketing system.

Drawback:

  • This requires handoffs from one group to another. This can introduce significant delays, inconsistencies and inaccuracies.
  • Lack of a common approach among the groups contributes to the problems of long build times and errors.
  • And blame game begins.

What is Agile Methodology

Agile is a process by which a team can manage a project by breaking it up into several stages and involving constant collaboration with stakeholders and continuous improvement and iteration at every stage. There are no surprises. Continuous collaboration is key, both among team members and with project stakeholders, to make fully-informed decisions.

Scrum is a framework for project management that emphasizes teamwork, accountability and iterative progress toward a well-defined goal….

The three pillars of Scrum are transparency, inspection and adaptation. The framework, which is often part of Agile software development, is named for a rugby formation. Scrum is one of the implementations of agile methodology. In which incremental builds are delivered to the customer in every two to three weeks’ time.

Get Complete Microsoft Azure DevOps training

Please follow and like us:
0

Azure DevOps Development and Operation


Click to below link – DevOps Lessons from Formula 1
https://www.devopsgroup.com/blog/devops-lessons-formula-1-part-2/

DevOps Practices

  • Agile planning. Together, we’ll create a backlog of work that everyone on the team and in management can see. We’ll prioritize the items so we know what we need to work on first. The backlog can include user stories, bugs, and any other information that helps us.
  • Continuous integration (CI). We’ll automate how we build and test our code. We’ll run that every time a team member commits changes to version control.
  • Continuous delivery (CD). CD is how we test, configure, and deploy from a build to a QA or production environment.
  • Monitoring. We’ll use telemetry to get information about an application’s performance and usage patterns. We can use that information to improve as we iterate.

How DevOps Works?

Under a DevOps model, development and operations teams are no longer “siloed.” Sometimes, these two teams are merged into a single team where the engineers work across the entire application lifecycle. Starting from design and development to testing automation and from continuous integration to continuous delivery, the team works together to achieve the desired goal. People having both development and operations skill sets work together and use various tools for CI-CD and Monitoring to respond quickly to customers need and fix issues and bugs.

Benefits of DevOps over Traditional IT

Speed + Rapid Delivery + Reliability + Scale + Improved Collaboration + Security

With DevOps, teams:

1.Deploy more frequently
In fact, some teams deploy up to dozens of times per day. Practices such as monitoring, continuous testing, database change management, and integrating security earlier in the software development process help elite performers deploy more frequently, and with greater predictability and security.
2.Reduce lead time from commit to deploy
Lead time is the time it takes for a feature to make it to the customer. By working in smaller batches, automating manual processes, and deploying more frequently, elite performers can achieve in hours or days what once took weeks or even months.
3.Reduce change failure rate
A new feature that fails in production or that causes other features to break can create a lost opportunity between you and your users. As high-performing teams mature, they reduce their change failure rate over time.
4.Recover from incidents more quickly
When incidents do occur, elite performers are able to recover more quickly. Acting on metrics helps elite performers recover more quickly while also deploying more frequently.

How you implement cloud infrastructure also matters. The cloud improves software delivery performance, and teams that adopt essential cloud characteristics are more likely to become elite performers.

The information here is based on DevOps research reports and surveys conducted with technical professionals worldwide.

Organizations that have implemented DevOps saw these benefits:

1.Improved Quality of Software Deployments -65%
2.More frequent Software Releases –63%
3.Improved visibility into IT process and requirements –61%
4.Cultural change (Collaboration and Cooperation) –55%
5.More responsiveness to Business Needs –55%
6.More Agile Development –51%
7.More Agile Change management process –45%
8.Improved Quality of Code –38%

Learn Microsoft Azure DevOps Online

Please follow and like us:
0