A Pen by Timeo Williams on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num = int(input('Enter a number: ')) | |
x = [] | |
count = 1 | |
while count < num: | |
if num % count == 0: | |
x.append(count) | |
count += 1 | |
else: | |
count += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | |
lena = len(a) - 1 | |
lenb = len(b) - 1 | |
i = 0 | |
share = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#a = [5, 10, 15, 20, 25, 30, 35, 40] | |
#b = a[::-1] | |
#print(b) | |
isPalindrome = input('Please enter a word: ') | |
isPalindrome1 = list(isPalindrome) # Converting string to list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [3,6,7,8,10,12,13] | |
even_numbers = [num for num in numbers if num % 2 == 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
play = input('Would you like to play rock paper scissors?') | |
while play == "yes": | |
user1 = input('Please enter your position(rock, paper,or scissors): ') | |
user2 = input('Please enter your position(rock, paper,or scissors): ') | |
#while user1 and user2 != "rock" or "paper" or "scissors": | |
#user1 = input('Please enter your position(rock, paper,or scissors): ') | |
#user2 = input('Please enter your position(rock, paper,or scissors): ') | |
if user1 == "rock" and user2 =="scissors": | |
print("rock wins") | |
play = "no" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random #Importing the random module | |
actual = random.randint(1, 9) | |
i = 0 #Setting up the counter/Initialization | |
guess = input('Try to guess what number I''m thinking about(from 1 - 9): ') | |
while guess != "exit": # We want this to run until the user enters the word exit. | |
if int(guess) == actual: | |
print('You entered the right answer') | |
elif int(guess) > actual: | |
print('You entered too high!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
a = [1,1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | |
c = [] | |
d = [] | |
if len(a) > len(b): | |
for i in a: | |
if i in b: | |
c.append(i) | |
elif len(a) < len(b): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In this program, I've created the function isPrime(), which allows the user to call the function, | |
#enter a number, and then immediately see if it is or isn't a prime number. | |
def isPrime(x): | |
for i in range(2,x): | |
if x % i == 0: | |
test = True | |
else: | |
test = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firstAndLast(a): | |
c =[] | |
c.append(a[0]) | |
c.append(a[-1]) | |
print(c) | |
a = [3, 4, 6, 7, 9] | |
firstAndLast(a) |
NewerOlder