BREAKING NEWS

Entertainment

Technology

Travelling

Thursday, 10 June 2021

hgcjdchggf

 ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg






ghjhgfv

How to Answer “What are Your Strengths and Weaknesses” in an Interview?

The Worst Job Interview Answers and What to Say Instead

 During a job interview, when candidates are asked – “What are your Strengths and Weaknesses?”, most of the time they either opt to become too humble while answering this question or they become a braggart – and let us tell you both the approaches are not ideal or recommended one. In fact, some of the candidates don’t even answer this question and prefer to keep quiet and reserved considering the question not that important which is also a wrong thing to do.


You need to understand when an interviewer asks a question about your strengths and weaknesses in the interview – he actually wants to assess your personality, particularly with respect to the company and the job role for which you’re applying. In general, the interviewer wants to identify if you are a right fit for the job opportunity or not, if you would be able to handle your job responsibilities or not, what are those personality traits of yours that will be really helpful in that particular job role, etc. by knowing your actual strengths and weaknesses.


Hence, you need to consider this question equally important as others. Moving further, now let’s understand what are those doubts or problems that a candidate, especially fresher, usually face while preparing an appropriate answer for such strengths and weaknesses related interview questions:


  • From where to start my answer to this question?
  • How can I praise myself in front of interviewers while talking about my strengths?
  • How to make my answer sound authentic and natural?
  • What if the said weaknesses of mine make a negative impact on the interviewer? etc.

But…you need to know if you follow the right set of approaches, you can easily resolve these above-mentioned issues or queries. And if you’re wondering about what are those correct approaches to prepare an impressive and accomplished answer to the “What are your Strengths and Weaknesses” question and to face it in a better way – we’ll tell you in this article but before that, let’s first take a look at an ideal sample answer to this question to understand things better:


Sample Answer

    “To start with my strengths, let me tell you that I’m a disciplined, team player, creative, and adaptable person. Also, I can say that I’m a quick learner. You can mention those strengths of yours that you think will add value in the particular job role There were many instances in the past that made me feel that these are some of my core strengths. Just for an example – here you can opt to narrate one or two such incidents where you’ve actually used or applied the said strengths whether it be during your previous job or internships, college life, or somewhere else. 


Also, I do guess that these strengths of mine are perfectly suitable for this job role such as here you can opt to describe how your strengths would be an added advantage in that job position


Moreover, talking about my weakness – here mention a general and genuine weakness of yours that wouldn’t impact much on the particular job position However, let me tell you this as well describe what you’ve done or are doing to improve the said weakness”


Now, to help you out in compiling the perfect answer to “What are your Strengths and Weaknesses” – below we’ve provided the most effective approaches that you all can consider:


Step 1: First and foremost, what you need to do is read the job description thoroughly. Yes, if you’re thinking that the job description has nothing to do with this general strength-weakness-related question then you are entirely wrong. After going through the job description, you will be able to find out what strengths or personality traits this particular job expects from the candidate – and then you can easily filter out your strengths and weaknesses accordingly to prepare your answer.  


Step 2: Now, you can start your answer by mentioning your strengths. The strengths you will tell here to the recruiter should be related to the job profile – however, it doesn’t mean that you’re mandatorily required to mention here technical strengths or skills relevant to the job profile, but you can mention those real-life strengths that you think will directly or indirectly help you out in the job role for which you’re applying. 


For example, if the particular job role requires you to work in constantly changing working conditions, you simply can mention ‘adaptability’ as your strength. Do remember to avoid mentioning any unnecessary or irrelevant strengths such as “I can do 100 sit-ups within 30 minutes” unless and until it is related to the targeted job role such as if you’re applying for a Gym trainer post or any other job that requires physical strength you surely can mention your pushups or sit-ups records.  


Step 3: Okay, once you’re done with telling your strengths to the interviewer, now what…?? So, now you need to give examples of those times when you actually used or applied the said strengths. Just for an example, if you’ve mentioned ‘Discipline‘ as your strength – you need to describe what made you feel so. ​It can be during your previous job or internships, college life, or somewhere else. The reason behind it is to justify to the interviewer that the strengths that you’re talking about are genuine, and you’re not faking it.

Also, if you’re thinking to skip this strength-justification part and giving an example then let us tell you that there are many chances that the interviewer may ask you directly about it in the next question. Hence, it would always be better if you will get already prepared for it.  


Step 4: Then, you can opt to describe how can you apply the said strengths or how they would be useful in the job role you are interviewing for. It will also help you to show the recruiter how well you’ve researched for the particular job role and company.  


Step 5: Now, move to the weaknesses part. Firstly, you need to remember that we all have weaknesses, and it’s quite a natural thing as nobody is perfect. You need to show that you are self-aware with all your personality traits whether it be your strengths or weaknesses. Hence, try to avoid giving answers like – “I’m a perfectionist”, etc.  Also, you don’t need to mask your strengths as your weaknesses by saying something like – “I work too hard”, etc. as it is a very outdated and not-so-effective approach. You need to mention those genuine weaknesses that will reflect your honesty to the interviewer. And most importantly, you’re strongly recommended to not tell more than one weakness.


Step 6: So, it would be clear to you in the above point that you can admit your weakness in front of the interview and one weakness would be sufficient – now you need to know what kind of weakness should you mention. Do remember that, the weakness should not be related to the core skill or requirement of the particular job role. Just for an example – if the job role requires a technically sound person, you can’t say like “I’m a little weak or slow in grasping technical things” or if it requires good communication skills, you can’t say like “Public Speaking is not my cup of tea”. You can go with several general and genuine weaknesses like “I find it difficult asking others for help”, etc.  


Step 7: Lastly, you can’t end your answer just by mentioning your weakness, but you need to tell about those things as well that you’ve done or are doing to overcome the said weakness. For example – if you’ve said that you’re not good with public speaking and even if it would not make a significant impact on the particular job role – still you can add something like “I’m constantly trying to improve this area. I’ve even started out to give some seminar sessions to my juniors to become proficient in it” in your answer. The main point is when the interviewer identifies that you’re not able to successfully acknowledge your weaknesses, but you also take relevant steps to get better at it – it really creates a positive impact on him/her.

                       27 Most Common Job Interview Questions and Answers | Inc.com

Key Points to Remember while Answering – “What are your Strengths and Weaknesses”:

  1. Try to avoid the use of weak words like “probably”, “maybe”, etc. while telling your strengths and weaknesses – they depict the lack of self-awareness in the candidate.
  2. Always take a pause and be thoughtful while giving the answer. It should sound genuine and shouldn’t look like something memorized.  
  3. Try not to appear overconfident or too modest while giving the answer.  
  4. Customize your answer as per the job role and company’s requirements from the candidate.

Now, after knowing the utmost significance, importance, and correct approach to answering these strengths and weaknesses-based questions in the interview – no one can stop to get ideally prepared for this question and to excel in your upcoming interviews. And honestly, it will really help you to stand out among other candidates and increase your chance of securing that job opportunity!!

Monday, 7 June 2021

Elon Musk threatened by hacker group Anonymous in a new video

Anonymous calls out 'narcissistic rich dude' Elon Musk | Dazed

 

The renowned hacker group has claimed that the Tesla CEO's quest to save the world is more rooted in a superiority and saviour complex than actual concern for humanity.


HIGHLIGHTS:

Hacker group Anonymous has called out Elon Musk for several of his cryptocurrency-related decisions in the recent past.

The group claims that Musk destroyed the lives of crypto investors with his company's decisions and "public temper tantrums "on social media.

It alleges that Musk's public image is a carefully created one and that it is now being exposed.

Elon Musk has become the latest target for the renowned hacker group Anonymous. In a new video elaborating on his wrongdoings, Anonymous has sent warning shots to the Tesla CEO, blaming him for destroying the lives of cryptocurrency investors with his tweets.


Click here👇

Anonymous Elon Musk Video Warning Over Bitcoin Memes: Is It Real?

In a video now doing the rounds on the Internet, Anonymous has called out Musk for his recent moves related to the cryptocurrency market. The video mentions that the recent tweets by Musk show a clear disregard for the average working person and that his "public temper tantrums "have liquidated the dreams of hardworking individuals.


"Reading from the comments on your Twitter posts, it seems that the games you have played with the crypto market have destroyed lives. Millions of retail investors were really counting on their crypto gains to improve their lives," Anonymous states in the video spotted by TMZ.


It further pinpoints several recent moves by the Tesla CEO, alleging that the decisions were made purely on the profitability basis for the company and with no regards to the future of cryptocurrency in general.


The most recent one, for instance, was the decision by Tesla to stop accepting Bitcoin payments for its electric cars. Anonymous says that it is widely believed that Tesla was forced to denounce this payment option.


It states that the company generates most of its revenue through the green carbon tax credit from the governments of the countries in which it operates. It alleges that the reason the use of Bitcoin was stopped was to maintain this flow of revenue from the government.


Anonymous alleges that Musk was already aware of the energy consumption associated with Bitcoin mining before citing it as a reason for not accepting Bitcoin payments for Tesla.


It further asserts that Musk acted clueless about this in "an attempt to play both sides of the fence" when the supply of green credit money from the government was threatened.


Elon's alleged unfair practices


These allegations by Anonymous were not limited to Bitcoin. The hacker group states that the Tesla CEO has enjoyed the "most favourable reputations of anyone in the billionaire class" for the past several years by tapping into the general public's desire for electric cars and space exploration. This "carefully created public image," however, is now being exposed.


Calling him "nothing more than another narcissistic rich dude," the video alleges that his quest to save the world is more rooted in a superiority and saviour complex than actual concern for humanity.


To highlight this, Anonymous cites the example of numerous complaints by Tesla employees over intolerable working conditions faced by them in the past years. It also mentions the young children employed in lithium mines to produce lithium, the major component of lithium-ion batteries used in electric cars, or most other electronic devices for that matter.


In the video, Anonymous states that Musk is "not the only show in town" and that his competition is growing every day. Blaming him for social media trolling and memes affecting the lives of many others, the video sends warning shots to the Tesla CEO, stating- "you may think you are the smartest person in the room, but now you have met your match."


It seems like Musk has taken note of the warning video. Since the video's appearance online, the Tesla CEO has sent out a tweet saying "Don’t kill what you hate, Save what you love," and has a new blacked-out Twitter profile picture. There is, however, a possibility that the updates have no relation to the Anonymous video.

Saturday, 5 June 2021

5 Python Books to Transfer Your Code to The Next Level

 

21 Books That Will Make 2021 Your Best Year Yet


Whether you are in data science, web development, or any technical field that requires code design and writing, you must have used Python. Python is one of the most popular and used programming languages at the moment. Python is so popular because of its simple syntax, how easy it’s to learn for new programmers or programmers shifting from other programming languages, and how versatile it is.

Although Python is easy to learn and use, writing good Python code is not as simple. It is a skill that requires writing a lot of code and being able to make it look pretty. Writing beautiful code is what differentiates an amateur programmer from an experienced one.

The Best Higher Education Books Of 2020

For your code to be beautiful, it needs to be easy to read and comprehend, lucid, and well balanced. It is a code that’s architecture, structure, and overall shape can tell you its intent without digging deeper into its application. Beautiful code often is divided into solid small pieces, each with its own purpose.


Most programmers can write code and solve problems, but you will stand out within the field if you can write beautiful solid code. In today’s article, I am addressing all levels of programmers; whether you’re a beginner, intermediate or advanced programmer, you can probably improve the quality of your code. This article will go through 5 Python books that focus on improving your code quality rather than teaching you how to code.

No1: Supercharged Python: Take Your Code to the Next Level

We will kick out this list with the Supercharged Python. This book was written by John Bennett, Brian Overland, and Brian Overland and was published in 2019. Like all other books in this list, this book targets those who already know the fundamentals of programming in general and know how to write basic code in Python.

This book will teach you how to harness the full power of Python and — as the title suggests — supercharge your applications. The book covers advanced list and string techniques, how to manage and handle binary files, how to master commonly used packages such as Numpy, and how to write solid concrete classes.

The book also addresses profilers, the magic of regular expression, and teaches you how to take advantage of 22 coding shortcuts and performance-enhancing tips and tricks to optimize your code execution. In a nutshell, the Supercharged Python teaches you how to write powerful, sophisticated Python applications faster and more efficiently.


No2: Python Tricks: A Buffet of Awesome Python Features

Next is one of my favorite Python books of all time, Python Tricks by the legend Dan Badar and published in 2017. If you’re looking for a good, concise book that teaches you how to write more “Pythonic” code, look no further, this book is for you.

Python Tricks illustrates valuable yet often overlooked Python features and best practices that will help you better understand Python and hence be able to write better codes using it. This book contains 43 subsections, each more valuable than the other and each containing a straightforward explanation with simple examples of how to use the proposed concepts.

This book covers many advanced topics such as commonly used patterns for cleaner Python code, how to effectively used functions, loops, and dictionaries, the best practices of object-oriented programming and classes, and some Pythonic productivity techniques. Moreover, this book comes with 12 bonus videos explaining the different concepts proposed in the book using short 11 minutes videos that you can listen to or watch any time and anywhere.

No3: Effective Python: 90 Ways to Write Better Python

Next up is a gem of a book written by Brett Slatkin in 2015, which is Effective Python: 90 ways to write better Python. This book covers 90 different. Concise and well-explained items discussing different aspects and concepts you can jump between in any order you find comfortable.

When this book was originally published, it only contained 59 ways to write better Python code, but the second edition expanded to include 30+ more new and useful concepts. Concepts like Pythonic thinking, functions, classes and inheritance, masterclasses, and concurrency and parallelism.

The book also covers — in-depth — how to package your code properly, write efficient documentation and manage dependency and virtual environment. Moreover, maintain your package by debugging it, testing it, and handling memory management for optimal execution. So, if you are done learning Python basics and want to go deeper into the language, this book is for you.


No4: Practices of the Python Pro

Next up is a relatively new book, Practices of the Python Pro, written by Dane Hillard and published in early 2020. This book targets professional programmers who want to write clean, well-organized, and maintainable application code using Python.

This book teaches you how to design, develop and write high-quality, professional code. Code that’s easy to understand, maintain and extend. The book focuses on giving you a solid foundation of how, why, and when to modularize your code, improve its quality, and reduce its overall complicity with solid and clear examples. Learning the techniques covered in this book, your code will be easy to read and reuse by others.

Practices of the Python Pro consist of mainly 4 sections. An introductory and a conclusion section and two sections cover all you need to produce beautiful code. Sections 2 and 3 take you through the process and mindset of designing large-scale software systems and how to make them solid, maintainable, and easy to browse.

No5: Intuitive Python: Productive Development for Projects that Last

Let’s conclude our list with the newest book of the batch, Intuitive Python, written by David Muller and just got published this year. Unlike all other books on this list, Intuitive Python goes beyond writing good, beautiful code in Python. This book provides you with the tools and packages you need to maintain your code.

Reading this book, you will learn how to run static and dynamic analysis tools on your code to detect and eliminate bugs in your code before you package and release it. You will also learn how to download and run third-party Packages without compromising the safety of your code. Furthermore, you will learn the most effective way to use the Python default debugger and use its interactive console.


Final Thoughts

Learning how to write code is not difficult, there are infinite — or that how it feels like — the number of materials and resources online that can teach you any programming language you want to learn. Not just teach to basics, but will take you through how to build many things using these languages.

One of the most used and talked about programming languages is Python. Python has gained much popularity for its simplicity to learn and the ability to use it to build solid applications in a variety of fields. But one of the tricky aspects about Python is, although it is easy to learn — compared to other programming languages — mastering Python requires a lot of practice and tons of skills.

If you can write beautiful, clear, concise, and solid code using Python, you can stand out among the thousands of Python programmers out there and will increase your chances of getting a job, a promotion, or shift careers. In this article, I proposed 5 books that focus on teaching you how to develop and work on your Python code writing skills and help you take your codes to the next level.

Friday, 4 June 2021

Python Factories for Scalable, Reusable, and Elegant Code

Top 10 Websites to Learn Python Programming for FREE in 2021 | by javinpaul  | Javarevisited | Medium 

In a real-life factory, the production of identical or similar objects is not done individually but rather streamlined in assembly lines. Similarly, the factory design pattern allows you to create software that is not tied to a specific product but rather can be reused in a number of similar applications. The factory pattern is one of the famous Gof (Gang of four) design patterns . It is a creational design pattern, and it encapsulates object creation inside a class called the factory. This kind of pattern promotes system flexibility by decoupling from the system the how, when, and by whom its objects are created. 

A factory is particularly useful when you need to create new types of objects. If object creation is dispersed throughout the code, then you will have to spend time to find the exact places in your code where the type of the object matters. In software engineering terms, this means that you have a significant amount of technical debt to deal with. This is particularly true in machine learning, as explained in. Machine learning can incur gigantic maintenance costs stemming from data dependencies, data drift, and hidden feedback loops. Factories have found their way into machine learning lately, through the creation of feature stores. Feature stores can be online or offline, and their main purpose is to abstract data transformations as they apply to different features and, in this way, enable faster development, better collaboration, efficient model deployment, and scaling.

1.0 An Example of Factories Implementation in Python

Let us look now at a specific example of how to use factories in Python. Let us assume that we want to create a new wardrobe for a son who is fresh out of college and got his first job at a bank as a quantitative financial analyst. Given that he is fluent in Python, he decides to implement a virtual wardrobe index. We will help him with the assignment of a “formality grade” to each outfit because he is perfectly capable of showing up in an important meeting with a T-shirt and ripped jeans.


As shown below, the virtual wardrobe index starts with the creation of two abstract factories, one for footwear(FootWear) and another for clothes (MensClothes). These are abstract classes, and they only serve the purpose of a template. Unlike Java, Python does not have an inherent abstract class type. Instead, it provides a module called abc, that provides the abstract class infrastructure. The colort and colorb variables of the MensClothes class represent the color of the top (shirt, sweater, etc.) and bottom (pants) respectively. Note we assign a default value “Brown” to the color of shoes and top and bottom (always a safe color).

Now let us implement two types of footwear, by defining the concrete classes Boots and Loafers. We inherit from the FootWear class and then override its shoespecs() method to implement specific actions for each concrete class.

Similarly, we create two concrete classes inheriting from MensClothes, SweaterAndCurdoroyPants, and ButtonDownShirtAndDressPants. Each concrete class overrides the abstract class method clothespecs(), in order to specify particulars for each style. Note that the clothespecs() method accepts a FootWear object, in order to match the color of the footwear with the color of the pants.

Abstract class Outfit below is a factory that provides methods for choices of clothes and shoes, choose_clothes() and choose_shoes() respectively, and has an instance attribute, formality.


    Concrete class LightColor_ColdAndCasualDay below inherits from abstract class Outfit and has the following methods:

(a) A constructor that specifies the formality and name variables. The formality variable is inherited from Outfit.

(b) An overridden form of the choose_clothes() method of class Outfit, which returns a SweaterAndCorduroyPants object.

(c ) An overridden form of the choose_shoes() method of Outfit, which returns a Boots object.


As we can see, things become more specific as we move up the hierarchy of classes, while the lower-level classes, such as FootWear, MensClothes, and Outfit are agnostic of what subclasses are created, where their objects are created, and how they are aggregated. A similar kind of structure is defined for the DarkColor_WarmSemiFormalDay class below, which defines methods that return a ButtonDownShirtAndDressPants object for clothes and a Loafers object for footwear.

In contrast to the abstract factories, we have seen so far, DarkColor_WarmSemiFormalDay and LightColor_ColdAndCasualDay are concrete factories. How they serve as factories of objects is illustrated in the definition of class Look that follows. Class Look is the orchestrating class that is responsible for object creation. As we can see below, its constructor takes a factory as an argument. In our limited wardrobe, the factory can be either a LightColor_ColdAndCasualDay or DarkColor_WarmSemiFormalDay object. When we create an object of class Look, the choose_clothes() and choose_shoes() of the factory are called which assign values to instance variables clo and sho respectively. These variables are then used in the all-important dress() method, which puts everything together and creates the complete look! This is scalable, reusable code because of the strategically placed object-creation encapsulation and polymorphism.

In the code snippet below, we can see our object creation and the invocation of the dress() method. Notice that we check whether the two objects are equal or whether object g2 is greater than object g1. In the definition of the Look class above, we define the output of the _eq_ operator as the output of the equality comparison of the formalities of the two objects. As we have discussed, our budding financial analyst knows nothing about formal style, so we needed to tell him in a specific way (formality rating), which looks are considered equivalent in terms of formality. So, 3 is the highest formality (business suit), and 0 is no formality (T-shirt and sneakers). The equals operation below returns False and the greater operation returns True because g2 has a higher formality rating (2) than g1 (1).

Finally, in the code snippet below, we import the current virtual wardrobe, which exists as a dictionary in a text file, and append to it the two new looks we created, with the name of the Outfit object as the key, and the formality as the value.

Thursday, 3 June 2021

Python’s Parts of Speech: Basic components of Python



A thorough understanding of the basic components of programming language is vital in the development of any code. This article outlines all the fundamental concepts of the Python language.


Just like how parts of speech form a basic building block of the English language, the following components form Python’s parts of speech.

1. Variables

Variables act as a noun in Python which provides a name for every string, constant, or numerical value. Variables are containers of the data, which can be accessed, edited, and used throughout the program. In Python, everything is treated as an object. An object is an entity that contains associated attributes and methods. The type of the data is not linked to the variable, instead of the object itself.


Example: x=’Car’

    The above variable x represents a String value ‘Car’.

    y=10

    whereas, variable y represents an integer number.


There are four basic data types supported in Python. Variables are named identifiers for any of these four types of values stored.


a. Integer

Integer consists of positive and negative whole numbers without a decimal point. There are no restrictions on the size of the number in Python.


Example : 10, 35,42 etc…

X=input(‘Enter a number:’)


b. Float

Floating-point numbers are real numbers with a decimal point.

Example: 10.1, 35.7,67.90


c. Complex

Complex numbers are represented by X+Yj, where X and Y are real numbers and j is the imaginary part. This data type is very useful in scientific calculations.

Example: 3+4j (where j is √-1).


d. String

The string consists of one or more characters enclosed in single, double, or triple quotes.


Example: str1= ‘This is Python Programming’


string | components of Python

As discussed earlier, every type in itself is an object. These objects have associated attributes and methods.


components of Python | string2

In the above example, x is an object which is of type complex. The object has attributes ‘real’ and ‘imag’, which give the details of the real and imaginary part of a number.


Now let’s look at a method available for float data type

components of Python | float


An attribute describes the characteristics of an object, whereas a method is a function available to an object. Here the function is_integer() check if the variable is an integer or float.


2. Collections

Collections are additional data types in Python required to handle special data values other than the ordinary ones.


Collections can be treated as a container of information just like a variable, but it allows flexibility with the kind of information it can hold.


There are four collection data types in Python.


a. Lists

Lists are ordered collection of series of data of various data types.


Example: Items added to the shopping cart.

    list_shopping = [‘Pen’,’Cool Drinks’,’Shirt’,’Toothpaste’]


The above shopping cart items contain a variety of goods required for a household.

In python terms every data is indexed. The index can be treated as a pointer to the information the list holds


lists

Each element is indexed in the order of insertion. In Python Index starts from ‘0’.


A list is an iterable object, which means each data element can be accessed sequentially using a for-loop.

implement lists | components of Python



b. Tuple

Tuples are ordered collection of data just like a list except, tuples cannot be altered once declared.


Example: Number of days in a week

    tuple_days=(‘Mon’,’Tue’,’Wed’,’Thurs’,’Frid’,’Sat’,’Sun’)


Tuples elements can be accessed just like lists using a for-loop


 tuple | components of Python

 


c. Set

Sets are an unordered collection of data, which does not allow duplicate values.


Example: Id of members who have booked tickets for the film show.

    set_users={1234,6789,1245,1567}


set

The elements of a set can be accessed similar to a list, except the elements are not displayed in the same order in which it was declared.


set1

 


d. Dictionary

Dictionaries are ordered collections of key-value data. It does not allow duplication of keys but duplicate values are allowed.


Example: Number and name of passengers who have reserved seats on the train.

    Dict_passengers = {1234 : ‘John’,1567 : ‘Mary’,1890 : ‘John’}

    dictionary

    dictionary 2

Methods keys() and values() can be used to access dictionary items.


3. Loops

Loops form an important part of any programming language. They are used to execute a set of instructions repeatedly until a condition is met where the loop can be terminated.


There are two main loops in Python.


a. While

While loop executes given set of instructions until the condition specified in the loop is satisfied.


Below is the structure of a while loop

while(condition)

         statement


while | components of Python

The above while-loop prints numbers 1 to 10 as the while condition fails when the value of x is more than 10.


b. for

For loop works on sequence data like lists, tuples, sets and execute the given set of statements as long as there are elements in the sequence.


for loop

The loop keeps iterating through the sequence until all the elements in the list are printed.


Following are a few special instructions that are used to alter the flow of the loop.


i) break

Break statement stops the execution and exits from the loop


break

The loop stops execution when the value of x reaches 30.


ii. continue

Continue statement suspends the execution of the current iteration and starts from the next one.  


continue

The program does not execute the print statement whenever the if-condition is met. It prints only the odd numbers in the list.


iii. pass

Whenever a programmer has a logic yet to be built for a loop but wants the execution of the program to continue without error, pass statements can be used.


pass

The program continues without throwing any error.


4. Conditional Statements

Conditional statements form an important part of the Python program where a set of instructions are executed only when a condition is satisfied.


There are three main conditional statements in Python.


a. Simple if

A set of instructions is executed only if the specified condition is met in the program


 if | components of Python

The print statement is executed only if the value of ‘x’ is greater than 10.


b. If ….else

An if-else statement offers an alternative to execute when the if condition is not met.


if else

The else statement has an alternate print statement to execute when ‘x’ is not greater than 10.


c. if …elif..else

This statement supports a series of conditions to be checked before the execution of a statement.


components of Python | if elif else

The above statement checks the value of ‘x’ if it is greater than 10, else it’s evaluated if it is lesser than 10, finally in the else block it concludes the ‘x’ value to be equal to 10.

 
Copyright © 2014 v tek. Designed by OddThemes | Distributed By Gooyaabi Templates