Skip to content

Instantly share code, notes, and snippets.

@azdafirmansyah
azdafirmansyah / Ex11CheckPrimaryNumber.py
Created November 30, 2017 07:44
Check Prime Number
'''
Exercise URL : http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html
Ask the user for a number and determine whether the number is prime or not.
(For those who have forgotten, a prime number is a number that has no divisors.)
'''
def check_primary(num):
result = True
for j in range(2,num):
if num % j == 0:
'''
Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25])
and makes a new list of only the first and last elements of the given list.
For practice, write this code inside a function.
'''
import random
list_data = random.sample(range(15),8)
def new_list(list_original):