Skip to main content

Things you must know before coding

wanna keen to learn to code but still confused about where to start ? Don't worry you are at the right blog, I'll be sharing from very basic concepts of coding. weather you have a technical background or not it doesn't matter just stay tuned with my blog, I can bet within a couple of days you will be able to write your own code and with weeks you will start thinking about logic how to solve any problem. Everything you need to know about programming  Programming is one of the top leading jobs in the current market, and it's growing every day. It's becoming more and more crucial to have a programmer in your company. And if you take into account that all the biggest companies in the world (Facebook, Twitter, Amazon etc.) are tied to programming, you'll understand the importance of it. That's why we'll try to teach you everything you need to know about programming.Basically, programming is defined as a process of developing and implementing various sets of i

List | Tuple |Sets | Dictionary in python

 


What is a List?

The simplest data structure in Python and is used to store a list of values. Lists are collections of items (strings, integers, or even other lists).

Each item in the list has an assigned index value.Lists are enclosed in [ ].

Each item in a list is separated by a comma. Unlike strings, lists are mutable, which means they can be changed.

List Creation:

Lists hold a sequence of values (just like strings can hold a sequence of characters).

Lists are very easy to create, these are some of the ways to make lists

What is Tuples?

A tuple is a sequence of values much like a list. The values stored in a tuple can be any type, and they are indexed by integers.

The important difference is that tuples are immutable.That we can’t change the elements of tuple once it is assigned whereas in the list, elements can be changed.

What is Sets?

  • Sets are unordered.
  • Set elements are unique. Duplicate elements are not allowed.
  • A set itself may be modified, but the elements contained in the set must be of an immutable type.
  • Sets can be used to perform mathematical set operations like union, intersection, symmetric difference etc.

What is Dictionary?

Use {} curly brackets to construct the dictionary, and [] square brackets to index it. Separate the key and value with colons: and with commas, between each pair. Keys must be quoted As with lists we can print out the dictionary by printing the reference to it. A dictionary maps a set of objects (keys) to another set of objects (values). A Python dictionary is a mapping of unique keys to values. Dictionaries are mutable, which means they can be changed. The values that the keys point to can be any Python value. Dictionaries are unordered, so the order that the keys are added doesn’t necessarily reflect what order they may be reported back.

Dictionaries and lists share the following characteristics:

  • Both are mutable.
  • Both are dynamic. They can grow and shrink as needed.
  • Both can be nested. A list can contain another list. A dictionary can contain another dictionary. A dictionary can also contain a list, and vice versa.

Dictionaries differ from lists primarily in how elements are accessed:

  • List elements are accessed by their position in the list, via indexing.
  • Dictionary elements are accessed via keys.

Comments

Popular posts from this blog

Things you must know before coding

wanna keen to learn to code but still confused about where to start ? Don't worry you are at the right blog, I'll be sharing from very basic concepts of coding. weather you have a technical background or not it doesn't matter just stay tuned with my blog, I can bet within a couple of days you will be able to write your own code and with weeks you will start thinking about logic how to solve any problem. Everything you need to know about programming  Programming is one of the top leading jobs in the current market, and it's growing every day. It's becoming more and more crucial to have a programmer in your company. And if you take into account that all the biggest companies in the world (Facebook, Twitter, Amazon etc.) are tied to programming, you'll understand the importance of it. That's why we'll try to teach you everything you need to know about programming.Basically, programming is defined as a process of developing and implementing various sets of i