Python Forum
Drop Dead Simple Interview Questions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drop Dead Simple Interview Questions
#1
What's some good interview questions?  There's FizzBuzz, and "print a ladder", what else do you have?

And sure, let's share answers why not.  Since I mentioned two, I'll go through them.

FizzBuzz:
In a given range (let's say 15), print something to the screen.  If the number is divisible by 3, print "Fizz".  If it's divisible by 5, print "Buzz".  If it's divisible by both, "FizzBuzz".  If it's not divisible by either, print the number itself.
>>> for ans in map(lambda n: "FizzBuzz" if 0==n%3 and 0==n%5 else "Fizz" if 0==n%3 else "Buzz" if 0==n%5 else n, range(1, 16)):
...     print(ans)
...
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
If you actually want the job, then this would be better (or having four print statements, and using "end=''" a lot):
>>> for n in range(1, 16):
...     ans = ""
...     if 0 == n%3:
...         ans += "Fizz"
...     if 0 == n%5:
...         ans += "Buzz"
...     if not ans:
...         ans = n
...     print(ans)
...
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Print a Ladder:
Given a range (again, let's say 15), print a given text that many times, to give the appearance of steps.
>>> def ladder():
...     text = input("What you wanna see? ")
...     return [text*n for n in range(int(input("How many steps? ")))]
...
>>> for step in ladder():
...     print(step)
...
What you wanna see? Spam
How many steps? 15

Spam
SpamSpam
SpamSpamSpam
SpamSpamSpamSpam
SpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam
SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam
Right.  So the questions should be super easy, and exist for no reason other than to prove the person knows more than just the requisite technology stack lingo to fake it.
Reply
#2
Quote:What's some good interview questions?
I like the idea of a thread showing possible or realistic questions asked....but i dont think the thread should be gen coding help. Maybe discussions? Or stickied in jobs? OR maybe tutorials....im not really sure where to put it.
Recommended Tutorials:
Reply
#3
Moved it Wink

Quote:If you actually want the job, then this would be better (or having four print statements, and using "end=''" a lot):
Njaa i could be that interviewer now a little functional programmering,and are happy with map and lambda.
The next question could then be,has it side effects Think
Reply
#4
Yeah, I had no idea, so I went general. I was thinking Jobs also, but the description is very specifically for job posters or seekers, not general info about jobs.
Reply
#5
Quote:I was thinking Jobs also, but the description is very specifically for job posters or seekers, not general info about jobs.
i personally think it would depend on how many people participate with different ideas, as to where it should go at the end. IF not a lot of people add things, i think it should stay here in discussions.
Recommended Tutorials:
Reply
#6
Simple file reading?  I'm not sure if this is better than csv, or if just seeing the general way people handle resources is more important...

>>> text = '''
... hello, my name is
...     wait, who am i?
... '''
>>> text = text.split('\n')
>>> with open('saved_data.txt', 'w') as f:
...     for line in text:
...         print(line, file=f)
...
>>> text = "spam"
>>> # now we don't have any reference to the original text floating around
...
>>> with open('saved_data.txt') as f:
...     for line in f:
...         print(line.rstrip())
...

hello, my name is
   wait, who am i?

>>>
Reply
#7
I never ask job applicants to write a program for me. I ask them to send me a program they've already written. That usually tells me plenty. Unfortunately, it's rarely anything I want to hear.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#8
It may also be his friends code
Reply
#9
I feel like writing code, right in front of someone, it a good idea. Even if it's not a real language, and just pseudocode. Gluing together snippets from google can only get you so far.
Reply
#10
I wouldn't ever give Fizzbuzz, I'd be afraid of insulting the candidate. Are you interviewing them for a specific role or position? Are they expected to be familiar with computer science?

A warmup question I often give is "write a function which takes in a string and returns true if the string represents a number." The candidate is meant to clarify the requirements, and be able to code it up after. If they write something that just handles non-negative integers, I start providing additional sample cases for negative and floating point numbers. They also often don't accommodate for "-", "." and sometimes even after that, "-.".
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pipenv & Requests Author Kenneth Reitz Interview Evrone 1 2,075 Jan-28-2021, 02:16 PM
Last Post: elizabethlvova
Star Flask Creator Armin Ronacher Interview elizabethlvova 1 1,923 Dec-16-2020, 09:10 AM
Last Post: Evrone
  Becoming a Self-Taught Programmer: Cory Althoff Interview Evrone 0 1,884 Dec-16-2020, 08:49 AM
Last Post: Evrone
  PEP 594 -- Removing dead batteries from the standard library ichabod801 3 2,754 May-31-2019, 01:23 PM
Last Post: heiner55
  Best resource to learn and pass interview oryucouk 5 3,055 May-18-2019, 05:19 AM
Last Post: heiner55
  MIT Interview with Guido Larz60+ 3 3,325 Nov-27-2018, 10:45 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020