Skip to content

Instantly share code, notes, and snippets.

@rishabhc32
Last active April 1, 2018 04:52
Show Gist options
  • Save rishabhc32/ee94657bf50cccea1028cb220adb0648 to your computer and use it in GitHub Desktop.
Save rishabhc32/ee94657bf50cccea1028cb220adb0648 to your computer and use it in GitHub Desktop.

These are my solutions, your mileage may vary.

Remember, no solution is wrong.

Question 1

ip = int(input())
var = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
ans = [x for x in var if x < ip]
print(ans)

Question 2

ip = input('Enter a string: ')
if ip == ip[::-1]:
	print('String is palindrome')
else:
	print('String is not palindrome')

Question 3

def make_new_list(l):
	new_list = [l[0], l[-1]]
	return new_list

a = [11,2,3,4,0]
ans = make_new_list(a)
print(ans)

Question 4

price_dictionary = {
  "banana": 1.50,
  "avocado": 0.99,
  "htomato": 0.89,
  "cherry": 3.00
}

key = input('Enter the fruit: ')
if key in price_dictionary:
	print('Price is {}'.format(price_dictionary[key]))
else:
	print('{} not found'.format(key))
@rishabhc32
Copy link
Author

Any doubts, leave in the comments section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment