<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Umme Abira Azmary</title>
    <description>The latest articles on DEV Community by Umme Abira Azmary (@mouly22).</description>
    <link>https://dev.to/mouly22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F788537%2F784b5481-66ba-4e31-919d-2e44d8211222.jpeg</url>
      <title>DEV Community: Umme Abira Azmary</title>
      <link>https://dev.to/mouly22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mouly22"/>
    <language>en</language>
    <item>
      <title>Cloud Computing, Microsoft Azure</title>
      <dc:creator>Umme Abira Azmary</dc:creator>
      <pubDate>Fri, 28 Jan 2022 12:28:49 +0000</pubDate>
      <link>https://dev.to/mouly22/cloud-computing-microsoft-azure-25gl</link>
      <guid>https://dev.to/mouly22/cloud-computing-microsoft-azure-25gl</guid>
      <description>&lt;h2&gt;Cloud Concepts&lt;/h2&gt;

&lt;h4&gt;Cloud computing is the delivery of various services such as data storage, servers, databases, networking, and software, over the Internet.&lt;/h4&gt;

&lt;p&gt;Cloud storage allows customers to save files to a remote database and retrieve them whenever they need them. So, a cloud environment provides various types of advantages.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;High availability:&lt;/b&gt; High availability refers to a computing infrastructure that allows it to &lt;strong&gt;&lt;em&gt;continue operating&lt;/em&gt;&lt;/strong&gt; even if some of its components fail. So, depending on the service-level agreement (SLA) that a customer choose, they can experience a continuous user experience with no apparent downtime of cloud-based apps.&lt;/p&gt;

&lt;p&gt;Availability = uptime / (uptime + downtime)&lt;/p&gt;

&lt;p&gt;[A cloud SLA (Service-Level Agreement) is an agreement between a cloud service provider and a customer that ensures specific terms that state the level of service that will be provided to a customer.]&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Scalability:&lt;/b&gt; Scalability is the ability of the system to support desired workload.&lt;br&gt;
Basically, scalability basically handles larger loads by adding resources either making hardware stronger (scale up) or adding additional nodes (scale out)&lt;/p&gt;

&lt;p&gt;It helps the system to scale out to ensure &lt;strong&gt;&lt;em&gt;capacity&lt;/em&gt;&lt;/strong&gt; during workload peaks and return to normal automatically when the peak drops.&lt;/p&gt;

&lt;p&gt;Apps in the cloud can scale vertically and horizontally.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Vertical Scalability&lt;/b&gt; increases compute capacity by adding &lt;strong&gt;&lt;em&gt;RAM or CPUs&lt;/em&gt;&lt;/strong&gt; to a virtual machine.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Horizontal Scalability&lt;/b&gt; increases compute capacity by adding &lt;strong&gt;&lt;em&gt;instances of resources, such as adding VMs&lt;/em&gt;&lt;/strong&gt; to the configuration.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Elasticity:&lt;/b&gt; Elasticity is the ability to scale automatically/dynamically.&lt;/p&gt;

&lt;p&gt;It provides the capacity to fit the resources needed to cope with loads dynamically.&lt;br&gt;
It quickly expands or decreases cloud-based resources to satisfy changing demands without worrying about capacity planning and engineering for peak usage.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Agility:&lt;/b&gt; &lt;br&gt;
Cloud Agility is the ability to react quickly.So, the speed and flexibility in the cloud which allow users to allocate and deallocate resources quickly is often called cloud agility.&lt;/p&gt;

&lt;p&gt;Because of Agility the cloud providers maintain resources and provision them, so user can concentrate on other issues such as security, monitoring, and analysis. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Geo-distribution:&lt;/b&gt; Geo distribution is designed in such a way to deploy apps and data to regional datacenters around the globe,which ensures the customers always have the best performance in their region.&lt;/p&gt;

&lt;p&gt;&lt;b&gt; Fault Tolerance: &lt;/b&gt; Fault tolerance is the ability to maintain system uptime while physical and service component failures happen.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Disaster recovery:&lt;/b&gt; Disaster Recovery is the ability of a system to recover from a human -induced disaster that has destroyed the primary data-center. &lt;/p&gt;

&lt;p&gt;Using cloud computing system we can deploy applications in multiple regions and data-replication in another region; and can also access it easily.&lt;br&gt;
As multiple times, we have mentioned regions, lets get to know more about it.&lt;/p&gt;

&lt;p&gt;&lt;b&gt; Region: &lt;/b&gt; Region is the location of your services.  A region is a set of datacenters connected through a regional low-latency network.&lt;/p&gt;

&lt;p&gt;Microsoft azure has the most number of regions currently, so it gives customers the flexibility to deploy application wherever needed.&lt;/p&gt;

&lt;p&gt;Two kinds of regions we need to keep in mind:&lt;/p&gt;

&lt;p&gt;1) Special government regions (US DoD Central, US Gov Virginia, etc.)&lt;/p&gt;

&lt;p&gt;2) Special partnered regions (China East, China North)&lt;/p&gt;

&lt;p&gt;&lt;b&gt; Region Pair: &lt;/b&gt; Each region pairing with another region makes region pair. Region pairs are static and we cannot choose it. &lt;/p&gt;

&lt;p&gt;&lt;b&gt; Availability Zone:&lt;/b&gt; Then comes the availability zone which is a regional feature. It is designed to protect from data center failures. Availability Zones are grouping of physically separate facilities, so if a zone goes down others continue working. But not all regions are supported in availability zone, a supported region has three or more zones.&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>azure</category>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>{"Dictionary" : "fun"}</title>
      <dc:creator>Umme Abira Azmary</dc:creator>
      <pubDate>Wed, 26 Jan 2022 14:28:14 +0000</pubDate>
      <link>https://dev.to/mouly22/dictionary-is-fun-1dh4</link>
      <guid>https://dev.to/mouly22/dictionary-is-fun-1dh4</guid>
      <description>&lt;p&gt;A dictionary is an unordered collection that consists of ​key-value​ pairs. Dictionaries are bounded by curly braces and have a list of ​key: value ​pairs which are separated by comma (,)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict1 = {}
dict1['name'] ='mouly'
dict1['address'] = 'bogura'
dict1['profession'] = 'student'
print(dict1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'name': 'mouly', 'address': 'bogura', 'profession': 'student'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, name, address, profession are keys. ​Keys​ need to be immutable type and keys are case sensitive.&lt;/p&gt;

&lt;h4&gt;Empty Dictionary &lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict2 = {}
print(dict2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Accessing a dictionary inside a dictionary&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m_zen = { 88017:'rihan', 88015:'kiran', 88018 : ['sonam','riki'], 88013: 'harmeonie', 88016 :{24: 'chinal',26:'sonu'}}
y = m_zen[88016][26]
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sonu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Adding two list as key,value in dictionary &lt;/h4&gt;

&lt;p&gt;For this, we have to use zip function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = ['darla','remina','sonam','kiran']
age = [23, 45, 3, 44]
res = dict(zip(name,age))
print(res)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'darla': 23, 'remina': 45, 'sonam': 3, 'kiran': 44}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Length of a dictionary &lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;store = {'bangla' : 3, 'english' : 4, 'german' : 5, 'arabic' : 2}
print(len(store))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Dictionaries are mutable &lt;/h4&gt;

&lt;p&gt;Dictionaries are mutable while keys are immutable. So we can change the values of a dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict3 = {'nila': 2345, 'mili': 2356, 'mona': 3456}
y = dict3['mona']
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3456
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how we can access the value of a specific key of a dictionary. &lt;/p&gt;

&lt;p&gt;We can also get the same value by using get function. The benefit of using get function is that, it does not give an error if we can not find value of a key; rather it gives None as output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict4 = {'nila': 2345, 'mili': 2356, 'mona': 3456}
y = dict4.get('nila')
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2345
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict4 = {'nila': 2345, 'mili': 2356, 'mona': 3456}
#x = dict4['rita']                                     #if we print it, it will give a KeyError
y = dict4.get('rita')
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; changing the value of a dictionary &lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dictt = {'saturn': 2, 'moon': 1, 'mars': 'red'}
print(dictt)
dictt['moon'] = 'earth'
print(dictt)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'saturn': 2, 'moon': 1, 'mars': 'red'}
{'saturn': 2, 'moon': 'earth', 'mars': 'red'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address = {'room':3,'home':4,'street':2}
print(address)
address['room']= address['room']+ 2
print(address)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'room': 3, 'home': 4, 'street': 2}
{'room': 5, 'home': 4, 'street': 2}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we can see how we the change value of a key of a dictionary.&lt;/p&gt;

&lt;h4&gt; Looping through a dictionary &lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;songs = { 'red':'All Too Well', 1989: 'Style', 'reputation' : 'Gorgeous'}
for i in songs.keys():
    print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;red
1989
reputation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;songs = { 'red':'All Too Well', 1989: 'Style', 'reputation' : 'Gorgeous'}
for i in songs.values():
    print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;All Too Well
Style
Gorgeous
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;songs = { 'red':'All Too Well', 1989: 'Style', 'reputation' : 'Gorgeous'}
for i,j in songs.items():
    print(i, j)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;red All Too Well
1989 Style
reputation Gorgeous
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;If I update a dictionary, then the updated list of keys will be displayed.&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;songs = { 'red':'All Too Well', 1989: 'Style', 'reputation' : 'Gorgeous'}
y = songs.keys()
songs['folklore'] = 'cardigan'
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict_keys(['red', 1989, 'reputation', 'folklore'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Determining if a key exists in Dictionary &lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d = {'red':'All Too Well', 1989: 'Style', 'reputation' : 'Gorgeous'}
if 'red' in d:
    print('yup')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; Adding Elements &lt;/h4&gt;

&lt;p&gt;For adding a new element in a dictionary, we have to add a key and then assign a value in that key and it will add by default as the last value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pdict = { 88017:'rihan', 'nila': 2345, 1989: 'Style', 88015:'kiran'}
pdict['mouly'] = 'cse'
print(pdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{88017: 'rihan', 'nila': 2345, 1989: 'Style', 88015: 'kiran', 'mouly': 'cse'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Update method&lt;/h4&gt;

&lt;p&gt;Or, we can use update method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pdict = { 88017:'rihan', 'nila': 2345, 1989: 'Style', 88015:'kiran'}
pdict.update({'mouly' : 'cse'})
print(pdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{88017: 'rihan', 'nila': 2345, 1989: 'Style', 88015: 'kiran', 'mouly': 'cse'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Del method &lt;/h4&gt;

&lt;p&gt;We can use del method for removing an element or simply remove the whole dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rdict = {'darla': 23, 'remina': 45, 'sonam': 3, 'kiran': 44}
del rdict
print(rdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NameError: name 'rdict' is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For removing any selective element from a dictinary,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rdict = {'darla': 23, 'remina': 45, 'sonam': 3, 'kiran': 44}
del rdict['sonam'] 
print(rdict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'darla': 23, 'remina': 45, 'kiran': 44}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Sorting dictionary &lt;/h4&gt;

&lt;p&gt;We can sort keys or values by using following method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jdict = {'saturn': 'sat', 'moon': 'ear', 'mars': 'red', 'venus': 2}
new = sorted(jdict.keys())
print(jdict)
print(new)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['mars', 'moon', 'saturn', 'venus']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;m_zen = { 88017:'rihan', 88015:'kiran', 88018 : ['sonam','riki'], 88013: 'harmeonie', 88016 :{24: 'chinal',26:'sonu'}}
y = sorted(m_zen.keys())
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[88013, 88015, 88016, 88017, 88018]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sorting values,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jdict = {'saturn': 'sat', 'moon': 'ear', 'mars': 'red', 'venus': 2}
new = sorted(jdict.values())
print(new)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: '&amp;lt;' not supported between instances of 'int' and 'str'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important thing to notice, we can not compare between the instances of integer and string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gdict = {'saturn': 'sat', 'moon': 'ear', 'mars': 'red', 'venus': 'blue'}
new = sorted(gdict.values())
print(new)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['blue', 'ear', 'red', 'sat']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Take a input dict from the user&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = 2
d = dict(input("Enter: ").split() for i in range(n))        #while taking input write one key-value in only line and go to the next line
print(d)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter: name mouly
Enter: student bracu
{'name': 'mouly', 'student': 'bracu'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val="""name mouly
age 21
home bogura"""

y = dict(x.split() for x in val.splitlines())
print(y)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'name': 'mouly', 'age': '21', 'home': 'bogura'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = int(input("enter a n value:"))
d = {}
for i in range(n):
    keys = input()           # here i have taken keys as strings
    values =input()          # here i have taken values as integers
    d[keys] = values
print(d)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enter a n value:2
name
mouly
age
21
{'name': 'mouly', 'age': '21'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n = int(input())            #n is the number of items you want to enter
d ={}                     
for i in range(n):        
    text = input().split()     #split the input text based on space &amp;amp; store in the list 'text'
    d[text[0]] = text[1]       #assign the 1st item to key and 2nd item to value of the dictionary
print(d)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
name mouly
street 2
{'name': 'mouly', 'street': '2'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>discuss</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is Module?</title>
      <dc:creator>Umme Abira Azmary</dc:creator>
      <pubDate>Fri, 21 Jan 2022 21:19:35 +0000</pubDate>
      <link>https://dev.to/mouly22/what-is-module-3bab</link>
      <guid>https://dev.to/mouly22/what-is-module-3bab</guid>
      <description>&lt;p&gt;A module is a file containing Python definitions and statements which we can use in other Python programs.&lt;br&gt;
A module is simply a “Python file” which contains code(functions, classes,lists etc)  we can reuse in multiple Python programs. &lt;/p&gt;

&lt;p&gt;Modules in Python can be of two types:&lt;/p&gt;

&lt;p&gt;Built-in Modules.&lt;br&gt;
User-defined Modules.&lt;/p&gt;

&lt;p&gt;Modules allows us to use the functionality we need when we need it, and it keeps our code cleaner.&lt;/p&gt;

&lt;p&gt;The functions we import as part of a module stays in their own namespace.(A namespace is simply a space within which all names are different from each other). The same name can be reused in different namespaces but two objects can’t have the same name within a single namespace.&lt;/p&gt;

&lt;p&gt;For example, Many cities have a street called “Main Street”,&lt;br&gt;
It is okay if 'different' cities have that 'same' street name but it’s very confusing if two streets in the same city have that same name!&lt;/p&gt;

&lt;p&gt;Another example is the folder organization of file systems. One can have a file called "todo" in her work folder as well as her personal folder, but she knows which is which because of the folder it’s in; each folder has its own namespace for files.&lt;/p&gt;

&lt;p&gt;One important note, human names are not part of a namespace that applies uniqueness; that’s why governments have invented unique identifiers to assign to people, like passport numbers.&lt;/p&gt;

&lt;p&gt;In order to use Python modules, we have to import them into a Python program.&lt;/p&gt;

&lt;p&gt;1)If we import morecode in a code, that imports everything in morecode.py. To invoke a function f1 that is defined in morecode.py, we can write morecode.f1().&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;morecode.f1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Note that we have to explicitly mention morecode again, to specify that we want the f1 function from the morecode namespace.If we just write f1(), python will look for an f1 that was defined in the current file, rather than in morecode.py.&lt;/p&gt;

&lt;p&gt;2)We can also give the imported module an alias (a different name, just for when we use it in our program). For example, after executing import morecode as mc, &lt;br&gt;
we would invoke f1 as mc.f1(). We have now given the morecode module the alias mc. Programmers often do this to make code easier to type.&lt;/p&gt;

&lt;p&gt;3)A third possibility for importing occurs when we only want to import SOME of the functionality from a module and we want to make those objects be part of the current module’s namespace. &lt;br&gt;
For example, we could write from morecode import f1. Then we could invoke f1 without referencing morecode again: f1().&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Basics of Python "String"</title>
      <dc:creator>Umme Abira Azmary</dc:creator>
      <pubDate>Sun, 09 Jan 2022 12:02:17 +0000</pubDate>
      <link>https://dev.to/mouly22/basics-of-python-string-44kg</link>
      <guid>https://dev.to/mouly22/basics-of-python-string-44kg</guid>
      <description>&lt;h2&gt; String &lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;String is a sequence of ordered characters (alphabets-lower case, upper case, numeric values, special symbols).&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Strings are either enclosed with single qutation marks('),double quotation marks('') and triple quotation marks('''). Also we can write multi line string using triple qutations(''', " " " both) The character order is always from left to right.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Hello! I am mouly")
print('Helloo! I am Mouly')
print('''This is
a multi line 
string and we
call it "Doc-Strings" ''')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello! I am mouly
Helloo! I am Mouly
This is
a multi line 
string and we
call it "Doc-Strings" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can use either single quotation or double quotation as long as we are consistant about which qutation we are using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("He was in the dead sea while listening 'Ocean Eyes'")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;He was in the dead sea while listening 'Ocean Eyes'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This qutation sequence can easily be maintained by using preceding backslash which is called as an &lt;strong&gt;&lt;em&gt;escape character( \ )&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print('I manage because I have to. Because I\'ve no other way out')
print("Don't you know,\"How can you ignore?\"")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I manage because I have to. Because I've no other way out
Don't you know,"How can you ignore?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An &lt;strong&gt;&lt;em&gt;empty string&lt;/em&gt;&lt;/strong&gt; also holds an indexing position&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(" ")                                     #empty string
print(' ')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; f-string &lt;/h4&gt;

&lt;p&gt;f-strings are string literals called as “formatted string literals” that have an f at the beginning and curly braces containing expressions that will be replaced with their values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wrd = 'looking'
who ='kid'
print(f'Here\'s {wrd} at you, {who}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here's looking at you, kid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Type&lt;/h4&gt;

&lt;p&gt;this built-in fuction returns the type of an object&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "alan walker"  
print(type(name))                             #type of name variable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;class 'str'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "5"                                      #this is a string
q = 5                                        #this is an integer
print(type(p))
print(type(q))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;class 'str'&amp;gt;
&amp;lt;class 'int'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though p and q might look same to you.. their types are different and there are different consequences for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "5"
q = 5
print(p)
print(q + 45)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5
50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "5"
q = 5
print(p + 45)                                 #this will give an error
print(q)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: can only concatenate str (not "int") to str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, p is a string. Even though 5 happens to look like a number, in python it's just a sequence of characters and we can't add a number to a sequence of characters.&lt;br&gt;
we can add them if we cast this p string into an integer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "5"
q = 5
print(int(p) + 45))                          #this won't give an error
print(q)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;50
5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "5"
print(p + "45")                              #string concetenation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;545
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we call a int of float to cast a string it needs to be a valid number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p = "20 taka"
print(p + 25)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: can only concatenate str (not "int") to str
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, python can't convert this string into integer.&lt;/p&gt;

&lt;p&gt;Strings are sequential collection datatype.This means a string is actually a collection of single characters.&lt;/p&gt;

&lt;h4&gt;Indexing&lt;/h4&gt;

&lt;p&gt;We can access an individual character of a string or part of a string using the indexing operator.&lt;br&gt;
For accessing individual character by it's position or &lt;strong&gt;&lt;em&gt;index value&lt;/em&gt;&lt;/strong&gt;. This index value always begins at &lt;strong&gt;&lt;em&gt;zero&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Indexing can be done in two ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Positive Indexing&lt;/em&gt;&lt;/strong&gt; is used to access characters from the left side of a string and it always starts from 0 and ends at the last character of the string. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Negative Indexing&lt;/em&gt;&lt;/strong&gt; is used to access characters from the right side of a string and it starts from -1 and ends at the first character of the string.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NwjdS1Kh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/Mouly22/Read-and-Learn-Python/blob/main/string%2520indexing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NwjdS1Kh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/Mouly22/Read-and-Learn-Python/blob/main/string%2520indexing.png" alt="String indexing " width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;REMEMBER,&lt;/em&gt;&lt;/strong&gt; A string with six characters have entities from 0 through 5. So if we want to access a 5th character of a string we'll use an index of 4.&lt;/p&gt;

&lt;p&gt;The basic string indexing structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string_name[index_value]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xmple = "we want to access"
print(xmple[0])
print(xmple[2])   
print(xmple[8])                                  #positive indexing
print(xmple[-1])                                 #negative indexing
print(xmple[18])                                 #index out of range
print(xmple[1.5])                                #type error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;w

t
s
IndexError
TypeError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the built-in function &lt;strong&gt;&lt;em&gt;len()&lt;/em&gt;&lt;/strong&gt; helps us determine the length of a string. So the last index of a stirng will always be &lt;strong&gt;&lt;em&gt;one less&lt;/em&gt;&lt;/strong&gt; than the length of that string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;len(string)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xmple = "we want to access"
print(len(xmple))                               #length of a string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;17
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we want to access last character of a string we can do either of them from below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xmple = "we want to access"
print(xmple[len(xmple)-1])
print(xmple[-1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;e
e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Slicing&lt;/h4&gt;

&lt;p&gt;Slicing is used for getting a substring of a particular string.This allows us to create a sub-string that is more than one character long. Colon(:) is used as a slicing operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Keep in mind&lt;/em&gt;&lt;/strong&gt; that, the slice operator leaves the original operator intact.&lt;/p&gt;

&lt;p&gt;Basic structure of slicing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string_name[beginning : end : step_size]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;beginning: The index where slicing starts (inclusive). If not provided, by default starts from index 0.&lt;/p&gt;

&lt;p&gt;end: The index where slicing stops(Not inclusive). If not provided, by default includes the rest of the string after “beginning”.&lt;/p&gt;

&lt;p&gt;step : increment of the index value. If not provided, by default the value is 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xmple = "we want to access"
print(xmple[1:9:1])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;e want t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example,the colon used in this slicing operator will return the characters from index 1 upto index 8(so not including index 9) and the increment will be 1.&lt;/p&gt;

&lt;h4&gt;String Operators&lt;/h4&gt;

&lt;h5&gt; Concatenation &lt;/h5&gt;

&lt;p&gt;We can &lt;strong&gt;&lt;em&gt;concatenate&lt;/em&gt;&lt;/strong&gt; strings by using the plus(+) sign.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var1 = "we want"
var2 = "to visit a"
var3 = "zoo"
var =  var1 +" "+ var2 +" "+ var3             #concetenation of a string
print(var)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;we want to visit a zoo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice one thing, this + sign doesn't add any &lt;strong&gt;&lt;em&gt;space&lt;/em&gt;&lt;/strong&gt; while concatenating. &lt;/p&gt;

&lt;h5&gt;Repetition &lt;/h5&gt;

&lt;p&gt;We can create a new string with the specified number of copies of the input string using this method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v = "repeat4time"*4
print(v)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repeat4timerepeat4timerepeat4timerepeat4time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Built-in methods&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It's important to remember that, Python is IMMUTABLE.&lt;/em&gt;&lt;/strong&gt; Immutable means once it has been created its value cannot be changed.&lt;br&gt;
So, each time we have to modify the values, we need to make a copy of the original one and make changes to the duplicate one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;me = "Abira"
me[1] = "e"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: 'str' object does not support item assignment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python has some built-in method to access or process characters in string.&lt;/p&gt;

&lt;p&gt;For example,&lt;/p&gt;

&lt;h4&gt;count(substring) method&lt;/h4&gt;

&lt;p&gt;we can use the count method to count the occurances of a particular substring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;place = "I want to visit USA"
print(place.count("i"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As python is &lt;strong&gt;&lt;em&gt;case-sensitive,&lt;/em&gt;&lt;/strong&gt; we can't access I here cause the ASCII value of I is different than i***&lt;/p&gt;

&lt;h4&gt;index(substring) method&lt;/h4&gt;

&lt;p&gt;we can use the index method to find the index of the &lt;strong&gt;&lt;em&gt;first occurance&lt;/em&gt;&lt;/strong&gt; of a given substring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;place = "I want to visit USA"
print(place.index("i"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;Upper() and lower() method&lt;/h4&gt;

&lt;p&gt;Upper returns the &lt;em&gt;**copy&lt;/em&gt;* of a given string in all uppercase letters; while lower returns the copy of a given string in all lowercase letters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;place = "I want to visit USA"
print(place.upper())
print(place.lower())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I WANT TO VISIT USA
i want to visit usa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;upper or lower method takes no arguments.&lt;/p&gt;

&lt;h4&gt;strip() method&lt;/h4&gt;

&lt;p&gt;this strip method returns the copy of a string by removing the &lt;strong&gt;&lt;em&gt;whitespaces&lt;/em&gt;&lt;/strong&gt; from before and after letters.&lt;/p&gt;

&lt;p&gt;Whitespaces refers to any character that represents a space in text like a tab,a space or a new line character.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new = "   Well this is another line   !     "       #Strips all whitespace characters from both ends.
print(new.strip())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Well this is another line   !
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice, the whitespace between characters are not removed, only the before and after letters whitespaces are removed.&lt;/p&gt;

&lt;h4&gt;replace(oldstring, newstring) method&lt;/h4&gt;

&lt;p&gt;the replace method replace every instance of oldstring with newstring in a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exm = "wd ard hdrd"
nexm = exm.replace('d','e')
print(nexm)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;we are here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt; split method&lt;/h4&gt;

&lt;p&gt;Split helps us breaking sentences of a string into more managable pieces.&lt;/p&gt;

&lt;p&gt;Split takes a &lt;strong&gt;&lt;em&gt;delimiter&lt;/em&gt;&lt;/strong&gt; and splits the string into sub-strings.The method returns a list where each item is a sub-string that is cut at every instance of that delimeter.&lt;/p&gt;

&lt;p&gt;For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;song = "Tell me why? Aint noting but a heartache. Tell me why? Aint noting but a mistake"
print(song.split("?"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['Tell me why', ' Aint noting but a heartache. Tell me why', ' Aint noting but a mistake']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This output comes as a list&lt;br&gt;
Here "?" is the delimeter.. so It will cut in those places and won't return the delimeter in output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = "Library is a place where you can find peace"
print(x.split(" "))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['Library', 'is', 'a', 'place', 'where', 'you', 'can', 'find', 'peace']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here my delimeter is a space. So the resulting list will include every word in that sentence but no spaces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = "Library is a place where you can find peace"
print(x.split("a"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['Libr', 'ry is ', ' pl', 'ce where you c', 'n find pe', 'ce']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, the split method won't include the delimeter in the list it returns.&lt;/p&gt;

&lt;h4&gt;Join method&lt;/h4&gt;

&lt;p&gt;The inverse of the split method is join. We can choose a desired separator string, (often called the glue) and join the list with the glue between each of the elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x = ["*light blue?", "sky", "it's raining hard","colin, where you go","?*"]
y = "! "
p = y.join(x)
print(p)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*light blue?! sky! it's raining hard! colin, where you go! ?*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can also use empty string or multi-character strings as glue.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
