Skip to content

Instantly share code, notes, and snippets.

View Ra1d7's full-sized avatar
๐Ÿ›Œ
Focusing

Moath Altarawneh Ra1d7

๐Ÿ›Œ
Focusing
View GitHub Profile
@Ra1d7
Ra1d7 / cows and bulls.py
Created August 24, 2019 21:30
PracticePython.org
import random
num = []
numtoguess=0
cows=0
bulls=0
for i in range(0,4):
num.append(random.randint(0,9))
numtoguess = int('{}{}{}{}'.format(num[0],num[1],num[2],num[3]))
def doguess():
global cows
prime = open(r'C:\Users\Raid7\Desktop\prac\primenumbers.txt')
happy = open(r'C:\Users\Raid7\Desktop\prac\happynumbers.txt')
primes = prime.readlines()
happy = happy.readlines()
for num in primes:
if num in happy:
print(num)
@Ra1d7
Ra1d7 / CowsAndBulls.py
Last active February 6, 2017 17:28
play cows and bulls game!
from random import randint
cows = 0
bulls = 0
ONE = randint(1,9)
TWO = randint(1,9)
THREE = randint(1,9)
FOUR = randint(1,9)
sec_num = str(ONE) + str(TWO) + str(THREE) + str(FOUR)
while True:
bulls = cows = 0
@Ra1d7
Ra1d7 / WebScraping.py
Created February 6, 2017 17:03
scrape nytimes.com for titles and print them
import requests
from bs4 import BeautifulSoup
r = requests.get('http://www.nytimes.com')
soup = BeautifulSoup(r.text,'lxml')
for story_heading in soup.find_all(class_="story-heading"):
try:
string = story_heading.a.text.replace(" ",'')
string = string.replace('\n','')
print(string)
except:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Media;
@Ra1d7
Ra1d7 / analyzestring.py
Created January 31, 2017 16:43
prints to you how many characters are in a string or a file
decid = input('would you like to analyze a string or a file?')
def printit(cheer):
if cheer is not None or cheer != ' ':
if textls.count(cheer) != 0:
print(cheer + ":" + str(textls.count(cheer)))
elif cheer is None:
print("space:" + str(textls.count(cheer)))
elif cheer == '\n':
@Ra1d7
Ra1d7 / passwordgen.py
Created January 31, 2017 01:01
Generates a password based on user's opinion
import random
decid = input('how string do you want your password to be?(weak/medium/strong): ')
leng = int(input('how long do you want your password to be?: '))
weak = 'a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z'.split(':')
medium = '0:1:2:3:4:5:6:7:8:9'.split(':')
strong = '!:@:#:$:%:^:&:*:_:-:=:.'.split(':')
password = ''
if decid.lower() == 'weak':
while len(password) < leng:
password += weak[random.randint(0,25)]
@Ra1d7
Ra1d7 / reversewords.py
Created January 31, 2017 00:20
this will reverse your string! (exercise 15)
list = input('enter a string that you want to be reversed: ').split(' ')
list.reverse()
print(' '.join(list))
@Ra1d7
Ra1d7 / removedups.py
Created January 31, 2017 00:14
remove duplicates (exercise 14)
listwithdups = [1,2,2,3,456,4,654,984,3,21,65,132,1,321,32,165,4,654,32,1,321,321,32,16,54,549,84,3,21,6,5,5,5,55,6,9,9,8,7,4,9,8,4,65,456]
def removedups():
return set(listwithdups)
print(removedups())
@Ra1d7
Ra1d7 / FibonacciNums.py
Created January 31, 2017 00:07
Generate fibonacci numbers (execrise 13)
num=int(input('Enter a number:'))
length=int(input('To what length u want it to be?:'))
nuz=0
list=[]
if len(str(num))>0:
list.append (num)
r=num+nuz
list.append (r)
while len(list)!=length:
dd=list[nuz]+list[nuz+1]