fbpx
Home Blog Page 1221

7 Python Interview Questions to Practice

0
7 Python Interview Questions to Practice

This article is part of a series by our friends at Career Karma, focused on tech industry careers. Check out previous posts on JavaScript technical interview prep, tech salaries, and technical resumes.

There is no better way to prepare for a technical interview than to practice a few coding questions. It may be impossible to account for every question you may be asked but any practice you do will help you build confidence and refine your programming skills.

The technical interview is not just about your coding skills. It’s about whether you can explain your code well and document what you have done. That’s another reason practice is so important. You’ll learn how to talk about Python programming and the code that you write.

Python interview questions

In this article, we’ve drafted seven Python interview questions to help you prepare for your next technical interview. For more interview prep, check out our guide to interviewing in the tech industry, including technical and behavioral interview tips.

Describe the concept of scope in Python with reference to local and global scope.

Scope is the region in which a variable is accessible in a program. There are two scopes in Python. Local scope is a variable that is defined inside a Python function. Variables with local scope can only be accessed inside a function.

Global scope is a variable that is declared in the main part of a program. Global variables are accessible throughout a program, including within functions. You can make a local variable global by using the “global” keyword inside a function.

What is the difference between a tuple and a list?

Both Python tuples and lists are used to store collections of data.

A list is declared as a collection of comma-separated values enclosed within square brackets whereas tuples are declared as a collection of values enclosed in curly brackets.

A list is mutable. This means their contents can be modified. Tuples are immutable. You cannot change the contents of a tuple. You must declare a new tuple instead if you want to modify the contents of a value inside a tuple.

Write a list comprehension that takes the following list and creates a new list containing the names of students whose names are four letters long:

students = [“Hannah”, “Peter”, “Luke”]

A list comprehension is a more “Pythonic” way to create a list. You can use list comprehensions to create lists based on the contents of an existing collection.

We can use the following code to create a list of students whose names contain four letters:

four_letter_names = [name for name in students if len(name) == 4]
# [“Luke”]

Our list comprehension iterates over all the students in the “students” variable. The len() string method calculates the length of each name. If the length of a name is equal to four, that name is added to our “four_letter_names” list. Otherwise, the name is not added to our list.

What is a lambda function? Why are they used?

A lambda function is a function that has no name. Lambda functions are commonly referred to as anonymous functions.

You can use a lambda function as an alternative to declaring a regular function as long as the function can fit onto one line. Consider the following example:

prices = [2.50, 3.10, 2.70]

over_three_dollars = list(filter(lambda price: (price > 3), prices))

This code goes through the “prices” list and returns only the prices that are greater than $3.00. In this example, we use a lambda function to define a rule for our filter() method. The rule states that a price should be added to a list if that price is greater than $3.00.

Our code returns [3.1] because there is only one value in our “prices” list that is greater than $3.00.

What is the __init__ method? Write an example of an __init__ method for the following properties:

Class Name: Student
Properties: name, date of birth, grade

The __init__ method defines a constructor in an object. This method is called when an object is created. __init__ is a reserved keyword.

__init__ methods can accept as many arguments as you specify when you declare the constructor. The __init__ method lets you define values that will be associated with an object.

An __init__ method should appear at the start of a new class, before any methods are declared. Consider the below example:

class Student():
	def __init__(self, name, date_of_birth, grade):
		self.name = name
		self.date_of_birth = date_of_birth
		self.grade = grade

We have declared a class called Student. Our class has three attributes: name, date_of_birth, and grade.

In our constructor, we assign the value of the arguments that the user specifies to their respective values in the “self” variable. This makes each value accessible in our object when we reference “self”.

We can declare an object of our class like so:

mark = Student(“Mark”, “19/02/2007”, 8)

We have created a student called Mark. Mark’s date of birth is 19/02/2007. He is in grade eight.

What is *args and **kwargs? Give an example of **kwargs in use.

The *args and **kwargs statements let you accept a variable number of arguments in a function.

The *args statement returns a tuple of arguments. You can access the items in the tuple using indexing. The **kwargs statement returns a dictionary of arguments. Arguments are mapped using keys and values.

*args is short for “arbitrary arguments” whereas **kwargs is short for “arbitrary keyword arguments”. This is because **kwargs arguments are associated with keywords.

We can use **kwargs to refer to an argument by a label that we assign when we pass a value as an argument:

def show_age(**student):
	print(“{} is {} years old.”.format(student[“name”], student[“age”]))

show_age(age=9, name=”Lynn”)

This function uses **kwargs to accept information about a student. Rather than accessing each argument as a variable, we use the “student” variable. The “student” variable is a dictionary of all the arguments we have passed.

The **kwargs statement is commonly used if you do not know how many arguments you are going to pass.

Explain the main features that make Python an object-oriented programming language.

Python, like Java and many other languages, is referred to as an object-oriented programming language. This means you can create objects and classes to help organize your code.

A class is a blueprint. They are used to define the structure of an object. A class can include the values that an object can store and the methods that can be run on an object.

An object is an instance of a class. When you initialize, or create, an object, you can specify attributes (values and methods) that are to be associated with that object.

For instance, “Student” could be the name of a class. This class would store all the values that can be associated with a student record at a school. “Alex” could be an object. This object would store details on a student whose name is Alex.

Wrapping up

Do not worry about preparing for every possible question that could come up. You’ll only be asked a few questions in your interview. Interview practice is about covering the essentials and building up your confidence.

As you ask and answer more interview questions, you’ll refine the craft of explaining your work. You’ll learn how to write more efficient code that will help set you aside as the best candidate for a job.

Whether you are doing your first technical interview, or whether you are already a senior engineer, practice will help you improve your chances of landing your dream job.

James Gallagher is a writer at Career Karma. He leads technical content on the Career Karma publication. James has authored dozens of articles for an audience of code newbies on Python, HTML, CSS, JavaScript, Java, and Linux.

How Do You Respond When People Ask, ‘Where Are You From?’

0
How Do You Respond When People Ask, ‘Where Are You From?’

Students in U.S. high schools can get free digital access to The New York Times until Sept. 1, 2021.


When people ask you where you’re from, is it easy for you to answer? Have you moved around a lot or have you always lived in the same place?

Are people usually satisfied with your response, or do you find yourself having to explain further?

In “The Complexity in ‘Where Are You From?’” Vanessa Hua writes about asking her parents that question:

When I asked my father where he was born, I never got a straight answer. Wuhan, he’d say. In other moments, he’d claim Wuchang.

I didn’t understand why he couldn’t state a simple fact. My assumption reflected my privilege, that of a girl who’d known only the peace and stability of the suburbs east of San Francisco. Much later, I would realize that his birthplace had been absorbed into Wuhan, a provincial capital formed from the sprawl of Wuchang, Hankou and Hanyang.

My father is gone now, but I’ve wondered what he would make of the coronavirus. He surely would have worried about his family more than himself.

It would have pained him that relations have cratered between his ancestral and adopted homelands, causing a backlash against Asian-Americans. “Go back to where you came from!” we’re told.

But where did we come from, and why does it matter? Among other Chinese, the question is a conversation starter in which we can situate ourselves and our people, in every far-flung corner of the diaspora. Your ancestral province might stamp itself upon your character, in your traits — determining your height, your ambitions and your looks.

Born in China, my parents fled to the island of Taiwan at the close of World War II. Later on, they came to the United States for graduate school in science and engineering.

I used to think my parents were cagey about their past because they wanted to focus on the future. Perhaps, growing up in the shadow of Communism, or in making a life for themselves in this country, they’d also learned not to disclose too much, for who knew how it might get turned against them?

All that might have been true, though now I understand I may have missed another reason. Just as my father couldn’t readily tell me where he was born, neither of my parents could say exactly where they were from because they’d moved around so much during their childhood, amid conflicts with Japanese forces in the years before and during World War II.

She continues, reflecting on her own experience about trying to explain where she is from:

I never faced such perils. Before leaving for college, I lived at the same address all my life, in the airy, light-filled house designed by my father, a structural engineer. It’s the same house where I now live with my twin sons, my husband and my mother.

And yet the question “where are you from?” is just as complicated for me to answer. Or rather, my initial reply — “I’m from California”— never seems to satisfy the strangers asking. Their mouths twitch and silence lengthens between us.

“I’m from the Bay Area,” I’ll clarify, even though I know I’m delaying the inevitable. It’s clear what they want to know, which perversely makes me want to hold out on them.

“But …” they trail off.

I can tell they think I’m misleading them. Some can’t hide their irritation that I’m not revealing information they feel entitled to having.

At last I’ll say, “I was born in the United States, but my parents are from China.”

They nod, pleased to confirm their suspicion that my family isn’t from here, that Asian-Americans are perpetual foreigners. They don’t realize they’re asking a question even my father couldn’t have answered.

Students, read the entire essay, then tell us:

  • How do you respond when people ask you where you are from? To you, is where you are from the town you were born in? The house you grew up in? The place you’ve lived that has felt the most like home? The country your parents or ancestors are from? Or something else?

  • Ms. Hua asks, “But where did we come from, and why does it matter?” What do you think? How much does where you are from matter to you? Why do we ask people this question? What can the answer reveal about a person? What can’t it tell us?

  • How important is it to you to know where your parents and family come from? What do you think this information can tell you about them? About yourself? How freely do your parents and other relatives talk about their past?

  • Ms. Hua writes that, for her, the question “Where are you from?” can sometimes carry extra weight; people aren’t satisfied until she answers in a way that confirms “their suspicion that my family isn’t from here, that Asian-Americans are perpetual foreigners.” Have you ever had an experience like hers? How did it make you feel? Have you ever doubted where someone is from because of how he or she looks? Does this essay make you think any differently about asking that question in the future?

  • Ms. Hua says of her grandmother’s necklace, which has been passed down in her family, “Where I’m from is everywhere it’s been.” Do you have an object that connects you to your home and to your family? What is it and what does it symbolize for you?


About Student Opinion

Find all our Student Opinion questions in this column.
Have an idea for a Student Opinion question? Tell us about it.
Learn more about how to use our free daily writing prompts for remote learning.

Students 13 and older in the United States and the United Kingdom, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Lesson of the Day: ‘Can Blood Manor’s Homicidal Clown Scare People in a Year Like 2020?’

0
Lesson of the Day: ‘Can Blood Manor’s Homicidal Clown Scare People in a Year Like 2020?’

7. After seeing these images and reading the article, would you want to visit Blood Manor or another haunted house this fall? Why or why not? Would you enjoy being a “scare actor”?

Bonus Scary Treat: If you were asked to consult on the design of a haunted house just for you, what elements, scenes, effects or experiences would you add to totally terrify you? Why?

Option 1: Share Your Experiences and Thoughts on Halloween.

  • Do you have a favorite Halloween memory?

  • Do you like to dress up for Halloween? Why or why not? What has been your favorite or scariest Halloween costume?

  • What has been the most interesting, original or scary costume you’ve seen someone else wear? What made it stand out?

Because of the coronavirus, Halloween won’t look like it has in the past. Depending on the incidence of the virus in your community, it may be safe to trick-or-treat in a modified way. The C.D.C.’s website provides advice for a “safer, alternative” Halloween, including outdoor costume parties and grab-and-go bags of candy.

In “Can Halloween Be Saved? Yes, Experts Say. Here’s How.,” Aimee Ortiz discusses the importance of normalcy in abnormal times with Dr. Tista Ghosh, an epidemiologist and senior medical director at Grand Rounds, a digital health care company:

It’s important to remember that these spooky festivities mean a lot to kids, Dr. Ghosh said.

“I think completely taking away Halloween could be detrimental to some of the mental health issues that kids are facing right now,” Dr. Ghosh said. She added that she always cautions people to “balance the risk of whatever activity they’re doing with mental health risks as well, and look for ways to minimize risk rather than reduce risk to zero because that’s just not possible.”

Do you agree that Halloween is important for children to maintain a sense of normalcy? Do you think it is possible to balance safety risks and the joys of the spooky fall tradition?

Will you be dressing up and trick-or-treating this year? Why or why not? How will you modify your or your family’s Halloween traditions ? What precautions recommended in the article and by the C.D.C. make the most sense for you and your community?

Option 2: Tell Us a Scary Story.

What’s the scariest story you have ever heard or told?

Share your own spooky tale, real or invented, by making a video or podcast, or by writing a story or crafting an essay.

For inspiration, you might listen to these creepy and chilling podcasts and audio series. Or check out this truly terrifying series of photos in “Scenes of Quiet Horror in America’s Haunted Houses,” and choose one to be the setting of a story you invent. Or, to find inspiration from history, check out this collection of Times articles from the archives about hauntings in the 19th century.

Long Distance Hugs

0
Long Distance Hugs

Students in U.S. high schools can get free digital access to The New York Times until Sept. 2021.

What message do you think this image is trying to convey? How does it relate to or comment on society or current events? Can you relate to it personally? What is your opinion of its message?

Tell us in the comments, then read the related article to learn more.


About Picture Prompts

Find all our Picture Prompts in this column.
Have an idea for a Picture Prompt? Tell us about it.
Teachers, discover more ways to teach with our Picture Prompts and learn how to use our free daily writing prompts for remote learning.

Students 13 and older in the United States and the United Kingdom, and 16 and older elsewhere, are invited to comment. All comments are moderated by the Learning Network staff, but please keep in mind that once your comment is accepted, it will be made public.

Word + Quiz: kerfuffle

0
Word + Quiz: kerfuffle

: a disorderly outburst or tumult caused by conflict

Picking a favorite bagel on National Bagel Day is bound to get any New York City mayor into trouble with some portion of his 8 million constituents, who are bound to have differing hard-held opinions.

But Bill de Blasio, following a failed presidential campaign, managed to cause a particularly unusual uproar.

… Then he crossed into treacherous territory for bagel aficionados: He said his go-to bagel was whole wheat with extra cream cheese. Toasted.

New Yorkers first responded with indignation, asserting that a good bagel should never be toasted.

Scorn immediately followed: Bagel Hole does not, in fact, toast its sacred treats.

Mr. de Blasio quickly deleted the post, and added a corrected version that removed all mention of the word toast.

He seemed to take the kerfuffle in stride, responding to one critic: “What can I say, I must have a hole in my memory.”

Our Eighth Annual 15-Second Vocabulary Video Challenge

0
Our Eighth Annual 15-Second Vocabulary Video Challenge

Please don’t forget: Every year, we have to disqualify many participants who fail to heed these three rules.

3. Work alone, with a partner or in a group.

4. Only one submission per student.

If you submit as part of a group, you cannot enter separately as an individual.

5. Your video should be no more than 15 seconds, but it can be shorter.

Please double check the video length after you upload the video to YouTube.

6. The video should be appropriate for a Times audience.

7. Your video should help viewers understand and learn your word.

You can act the word out, animate it, use puppets, draw, sing a song, create a dance, incorporate photographs, create a Claymation or do anything else.

8. To participate in this contest, students, teachers or parents need to upload entries to YouTube.

Entrants must make sure their privacy settings are set to “public” or “unlisted” so our judges can view the submissions. We will judge only the videos that have been posted to YouTube — not other services — because YouTube videos more easily embed in our system. Be sure that all entries abide by the YouTube Terms of Service. Also, be certain that you meet the age requirements to post videos on YouTube as explained in the company’s Terms of Service. If you are a minor in your country, you must always have your parent’s or guardian’s permission before using the service. If you do not meet YouTube’s age requirements, you can have a parent or guardian post on your behalf. If you are a teacher posting a video on behalf of students, be sure that you have permission from their parents or guardians to post any content.

8. Be sure to use only sound effects or music that is not copyright protected.

If you incorporate music or sound effects in your video, consider creating your own. Or, if you want to use royalty-free music and sound effects, such as those found on sites like Freesound or SoundBible, be sure to follow the attribution instructions for how to give proper credit. That may include listing the sound creator’s name in the YouTube video description.

Alison’s Working from Home Toolkit

0
Alison’s Working from Home Toolkit

The coronavirus pandemic has meant that many of us have had to rethink, reorganise and reshape our daily lives. Lockdowns, quarantining and self-isolating have meant that regular routines have been disrupted and new, adaptable ways of doing things have had to be found. Working from home is just one of the many “new normals” we had to get used to. 

For most of 2020, millions of people around the world have been working from home. Many employees have been working remotely for the first time in their career and often in jobs that have never before been conducted outside of an office setting.

For many employees, working from home has been a new, and largely positive, experience. Remote working has meant less commuting, a better work-life balance and even increased productivity.

But for all its positives, working from home can lead to difficulties and can take some adjusting. From missing the professional environment to having to be more flexible with time, remote working can throw up a variety of issues. For many people entering the workforce for the first time in 2020, their first job will be a remote job and these new workers won’t have coworkers on-site to help them learn the ropes.

However, as some companies have given up their office space completely due to the coronavirus crisis, working from home is here to stay for many employees. Here at Alison, for example, we have downsized our main office space in Galway by 80% and are moving towards a fully remote workplace model.

So to help you adapt to the future of work, Alison has selected the key courses necessary to help remote employees transition smoothly to working from home.

Free courses to get you started

From time management to how to use Google’s suite of free apps, this list of free online courses will get you set up to work remotely.

  • Time Management – From children to pets, working from home can mean having to juggle a variety of commitments while trying to complete a day’s work. This course teaches you how to keep track of your work hours, save time, reduce stress and stay productive.
  • Presentation and Speaking Skills for Webinars – Working from home often means being part of a remote team and having to communicate online. Learn how to speak confidently online and how to create exciting and engaging presentations!
  • Software skills – All the courses you need to manage your remote work effectively, including Microsoft Excel, Microsoft Teams and Microsoft Office.
  • Stress Management – Working from home can present a variety of unique challenges. This course outlines how stress is caused and how it can be coped with.
  • Zoom Video Conferencing – Zoom has become an essential tool for millions of employees in recent months. Learn how to navigate one of the most important software programmes for any remote worker at home! 
  • Microsoft Teams – This course has everything you need to know about this collaboration platform. Learning how to navigate this shared workspace software fluently will make remote working a much more natural experience.
  • From standard Google Apps to Google Apps for Business and even How to Build Your Business Online, Alison has all of the necessary courses to make you an expert in all of the tools on offer from Google

 

Light reading material to get you a step ahead of the rest

 

Of course, the pandemic hasn’t just meant more working from home – it’s meant a lot more time at home generally. And so when you need a break, Alison has everything you need to unwind and relax, from dabbling in a new language to yoga, from learning about history to gardening. Whether working – or playing – from home, Alison has got you covered!

 

Yohannes Mekuria: “Alison courses have given me confidence in whatever activities I am assigned.”

0
Yohannes Mekuria: “Alison courses have given me confidence in whatever activities I am assigned.”

“My name is Yohannes Mekuria. I am 23 years old, born and raised in Ethiopia. From the very beginning, I was a high achieving student. I received my first degree from Samara University in Public Health with a very great distinction in 2019.”

How did you learn about Alison?

One lucky day, I was hoping to get an online education and started searching for “the best site for online education” on Google. From the many results, I found Alison to be very interesting and easy to use. In addition, I found the exact courses which I had been eager to learn for months. 

 

What was your first course on Alison, and why did you choose it?

My first course on Alison was Essential Management Skills for the Workplace. I chose this course because I had always wanted to learn about managing people and resources in my work. I was keen to learn managerial skills. Since then, I have also gained a Diploma in Project Management in Practice, Diploma in Human Nutrition, Diploma in Human Resources, and Diploma in English Language and Literature.

How have Alison courses affected your career?

All these Alison courses have helped to boost my knowledge in different areas of both my day-to-day activities and, most importantly, in my career. They have given me confidence in whatever activities I am assigned.

What’s your favourite way to relax from studying?

After a productive day of studying, I relax by listening to music, watching movies or taking a long walk with my friends. 

 

Where are you working and what are you studying now?

Now I am working in a private college in Adama town, which is near Addis Ababa, the capital of Ethiopia. I am currently studying the Advanced Diploma in Managerial Skills for Interpersonal Dynamics

What’s next for you, in terms of education or work?

In the next couple of months, I have a plan to start my master’s degree in Public Health.

If you could learn absolutely anything in the world from an Alison course, what would it be?

If I could learn absolutely anything in the world from an Alison course it would be a Ph.D. in Public Health.

What would you say to someone if they asked you about Alison? Would you recommend it and why?

If someone asked me, I would confidently recommend Alison because it’s the best online education site to learn. You can gain different kinds of knowledge from wherever you are.

Lakshay Soni: “Alison is the best educational platform I have ever used.”

0
Lakshay Soni: “Alison is the best educational platform I have ever used.”

“My name is Lakshay Soni. I’m a student from a middle-class family. I am pursuing a Bachelor of Commerce from the School of Open Learning, University of Delhi. Alison has helped me a lot in developing my thinking, increasing my skills, and increasing my levels of confidence. 

How did you learn about Alison?

Through a friend’s recommendation.

What was your first course on Alison, and why did you choose it?

It was a course in Human Resources Management. I chose it because it was a trending course. It’s a very in-demand course right now.

What’s your favourite way to relax from studying?

Listening to music.

Where are you working and what are you studying now?

I am working for SkyKing and studying for my Bachelor of Commerce.

 

What’s next for you, in terms of education or work?

My next priority is a master’s of Commerce.

If you could learn absolutely anything in the world from an Alison course, what would it be?

I want to learn about coding. CSS, JavaScript – I have a great interest in that area. 

What would you say to someone if they asked you about Alison? Would you recommend it and why?

Alison is the best educational platform I have ever used. After using Alison, my confidence in interviews increased so much that, in every interview, the employer had to select me!

Isaac Kaputula: “Alison gives opportunities to all the people who need education in their lives, inexpensively and flexibly.”

0
Isaac Kaputula: “Alison gives opportunities to all the people who need education in their lives, inexpensively and flexibly.”

“I am a twenty-eight year old man, born to a family of two – a boy and a girl. I was the first born. I lost my mother before I started primary school and my father abandoned us when I was seven years old. I started living with my grandmother, my mother’s mother, and my uncle decided to send me to school. He died when I was in grade seven. There is a lot to tell about me but to cut a long story short, I have done a lot to make sure that, despite hardships, I could get an education, though this path has never been easy. I started studying at the Daughters of Mary Immaculate – St Eugene University, majoring in Science. However, in fourth year I dropped out as I no longer had the finances. But instead of just sitting back, I decided to start studying with Alison. This and other stories are what makes me as Isaac Kaputula.”

How did you learn about Alison?

I am always online and, one day, I was searching for schools where I could study online in my own time and at an affordable price. I saw an advertisement pop up showing me a place that I could study online for free and I started the programme but then realised there was no certification. So I started looking again for a place that would certify me so that I would be able to find a job. Eventually, I saw an advertisement to study online for free with Alison and I signed up. That’s how I heard about Alison.

What was your first course on Alison, and why did you choose it?

Diploma in Marketing. I chose this course because I wanted to gain quality experience as well as being able to compete well in finding a job that would require me to have marketing qualifications.

 

How have Alison courses affected your career?

After getting my diploma, I am able to compete with other graduates in my country, even though some of them went to high class universities.

What’s your favourite way to relax from studying?

I love to visit different places, read books, play chess and meet new people.

Where are you working and what are you studying now?

I have just started working in Administration for Mafundzalo Ranch Company Ltd and I am also studying Information Technology with Alison.

What’s next for you, in terms of education or work?

I’m hoping to do my master’s in Marketing.

If you could learn absolutely anything in the world from an Alison course, what would it be?

How to be practical.

What would you say to someone if they asked you about Alison? Would you recommend it and why?

I would advise them to start studying at Alison to get the qualification they need. I always recommend, and will forever recommend, Alison. Alison gives opportunities to all the people who need education in their lives, inexpensively and flexibly.