blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
d1825afd10ce13925171fa81cefb8541c16b7378
anvartdinovtimurlinux/ADPY-12
/1.2/generator.py
367
3.5625
4
import hashlib def md5_generator_from_file(path_to_file,): with open(path_to_file, 'r', encoding='utf-8') as f: for line in f: result = hashlib.md5(line.encode()) yield result.hexdigest() if __name__ == '__main__': for i, line in enumerate(md5_generator_from_file('result.txt'...
1532177b8dafbe4192f883cc294ad5622dae5532
jaramir/AoC2018
/day9/part1.py
1,391
3.734375
4
class Node: def __init__(self, value, prev=None, next=None): self.value = value self.next = self if next is None else next self.prev = self if prev is None else prev def insert(self, value): node = Node(value, self, self.next) self.next.prev = node self.next = no...
dc010a904846d5df1f68cb5895206cf5032acc84
jaramir/AoC2018
/day6/part1.py
1,547
3.625
4
def neighbours(cell): x, y = cell return {(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)} def contested(point, cells): for neighbour in neighbours(point): if neighbour in cells: return True else: return False def step(families): new_f...
41af103a812a599e376b79251c7f1c76a01fe914
KevinOluoch/Andela-Labs
/missing_number_lab.py
787
4.4375
4
def find_missing( list1, list2 ): """When presented with two arrays, all containing positive integers, with one of the arrays having one extra number, it returns the extra number as shown in examples below: [1,2,3] and [1,2,3,4] will return 4 [4,66,7] and [66,77,7,4] will return 77 """ ...
f21f3a0a880d6b17fb8d99257c0b1a7d5b56d5ec
siamang/weather
/weather.py
629
3.65625
4
# -*- coding: utf-8 -*- # weather.py # # display temperature import urllib2 import json city = raw_input("City: ") state = raw_input("State: ") with open("key.txt") as key: APIkey = key.readline().strip() http = "http://api.wunderground.com/api/" + APIkey + "/geolookup/conditions/q/" + state + "/" + city + ".jso...
d8edaa78416dd7379814a590c3492415f20bd4b7
haden-liu/streamlit
/app.py
685
3.765625
4
import streamlit as st import pandas as pd import numpy as np import pydeck as pdk DATA_URL = ( "Jan_2020_ontime.csv" ) st.title("Flight Delay Analysis Jan 2020") st.markdown("This application is a Streamlit dashboard that" "to analyze flight delay in US Cities") @st.cache(persist=True) def load_data(nrows): da...
b1f2fa7118378dea5df54f6957cc0a00a33fb88d
Lakshya7312/c131
/131.py
867
3.625
4
import csv import pandas as pd df = pd.read_csv(r"C:\Users\Lenovo\Desktop\Python Projects\Stardata.csv") # kg = 1.989e+30 finaldata = df.dropna() finaldata.isnull().sum() finaldata #print(finaldata) #print(df) finaldata mass = finaldata["Mass"].tolist() radius = finaldata["Radius"].tolist() gravity = ...
b2875d7737c5fd6cc06a5299f9f8c888c93bebb8
byhay1/Practice-Python
/Repl.it-Practice/forloops.py
1,856
4.71875
5
#-------- #Lets do for loops #used to iterate through an object, list, etc. # syntax # my_iterable = [1,2,3] # for item_name in my_iterable # print(item_name) # KEY WORDS: for, in #-------- #first for loop example mylist = [1,2,3,4,5,6,7,8,9,10] #for then variable, you chose the variable print('\n') for num in m...
29d08b7acb73e2baeb8a2daf67be103e1ad302fc
byhay1/Practice-Python
/Repl.it-Practice/tuples.py
828
4.1875
4
#------------ #tuples are immutable and similar to list #FORMAT of a tuple == (1,2,3) #------------ # create a tuple similar to a list but use '()' instead of '[]' #define tuple t = (1,2,3) t2 = ('a','a','b') mylist = [1,2,3] #want to find the class type use the typle function type(PUTinVAR) print('',"Find the type o...
4f3e7af26400a2f4c309cffa69d5a6f874819731
byhay1/Practice-Python
/Repl.it-Practice/OOPattributeClass.py
2,069
4.5
4
#---------- # Introduction to OOP: # Attributes and Class Keywords # #---------- import math mylist = [1,2,3] myset = set() #built in objects type(myset) type(list) ####### #define a user defined object #Classes follow CamelCasing ####### #Do nothing sample class class Sample(): pass #set variable to class my_sa...
6ca35f085ec691266a89ebbe24479424bb7f11ce
sowmyadavuluri/Learnings
/cr_list_tuple_from_arr.py
206
3.984375
4
# lists and tuples from input a = int(input("enter first number: ")) b = int(input("enter second number: ")) c = int(input("enter third number: ")) list = [a,b,c] print(list) tuple = (a,b,c) print(tuple)
eef86cb4c54bf7d0b38ced84acff83220b0304e3
jongwlee17/teampak
/Python Assignment/Assignment 5.py
988
4.34375
4
""" Exercise 5: Take two lists, say for example these two: 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] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists...
78bc59ffaf91ff24bc23fb87439767e4ac7ce0bf
jongwlee17/teampak
/Python Assignment/Assignment 8.py
2,139
4
4
""" Exercise 8: Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Remember the rules: - Rock beats scissors - Scissors beats paper - Paper beats rock """ first_p...
8dc7d1a00f7a0083ca99da898165a5ba1163f166
heymayras/atividades_python
/asd.py
200
4
4
if ((not False and True) and (True or False or False)): print("Verdadeiro") else: print("Falso") if (not (5 == 5) and (not (Ture or False))): print("Verdadeiro") else: print("Falso")
ee885f888260cf82625a0658de0c8f7718b7b28a
UWMRO/ScienceCamera
/evora/common/logging/my_logger.py
1,911
3.609375
4
#!/usr/bin/env python2 from __future__ import division, print_function import os import logging from datetime import date def myLogger(loggerName, fileName=None): """ This returns a custom python logger. This initializes the logger characteristics. Passing in a file name will send logging output, not...
987c9e3ff8225d1666e907ce2857379229bc8048
akhilbommu/July_LeetCode_Challenge
/Day16-Pow(x,n).py
191
3.578125
4
class Power: def myPow(self, x: float, n: int) -> float: return pow(x, n) obj = Power() print(obj.myPow(2.00000, 10)) print(obj.myPow(2.10000, 3)) print(obj.myPow(2.00000, -2))
0cf699ef7a6372fdb4c251a2ed9653b6a873d4c1
akhilbommu/July_LeetCode_Challenge
/Day14-AngleBetweenHandsOfClock.py
399
3.765625
4
class AngleBetweenHandsOfClock: def angleClock(self, hrs: int, mins: int) -> float: hrs %= 12 hours = hrs*30 + mins/2 mins = 6 * mins return min(abs(hours-mins), 360-abs(mins-hours)) obj = AngleBetweenHandsOfClock() print(obj.angleClock(12, 30)) print(obj.angleClock(3, 30)) print(o...
1d3b02a7b85a002a205ca90445a9df981007a27d
Artem7898/-Python-client-server-applications
/Python_lesson_7_client_app/service.py
687
3.609375
4
import socket # Задаем адрес сервера SERVER_ADDRESS = ('localhost', 8888) # Настраиваем сокет server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(SERVER_ADDRESS) server_socket.listen(10) print('сервер работает, пожалуйста, нажмите ctrl + c для остановки') # Слушаем запросы while True...
3f6665eb79095563cbc774af8fb87c24d398455e
fossabot/bhandar
/convertbase.py
593
3.5
4
#!/usr/bin/env python import sys import string def convert(no, ibase, obase): newno = int(no, ibase) if obase == 10: return str(newno) data = dict(enumerate(string.digits+string.ascii_uppercase)) ret = [] while newno: ret.insert(0, str(data[newno % obase])) newno = int(newno...
07b7c56ffaa62eef2841fb04a8ade3413e14cb41
sebastianslupinski/python-OOP-battleship-
/game.py
4,059
3.859375
4
import os from player import Player from ocean import Ocean from square import Square from ship import Ship import random import time class PlayBattleships(): def __init__(self, player1, player2): self.player1 = player1 self.player2 = player2 def placement_validation(self, ship_list, player,...
16a1ced785b92534c788b76216f5d7a261e03de3
yannikinniger/draughts-game
/src/model/pieces/AbstractPiece.py
891
3.609375
4
import abc from model.pieces.InvalidMoveException import InvalidMoveException class AbstractPiece: def __init__(self, owner, location, direction): self.owner = owner self.location = location self.direction = direction def move(self, location): """ Moves the piece to ...
0790e92f564be4ce7329f600d37c04cc11baea91
TheodoreNestel/Theo-Capstone-One
/models.py
3,208
3.546875
4
from flask_sqlalchemy import SQLAlchemy from flask_bcrypt import Bcrypt #setups to allow Bcrypt and sqlalchemy to function bcrypt = Bcrypt() db = SQLAlchemy() # Model ############### class User(db.Model): __tablename__ = 'users' #we start with a unique id for each user being incremented automatically ...
968efa71c64032cb0fde2fcd03f347bdf3c95e5d
yunussalta/pg1926odevleri
/ödevdir/python ödev3.py
255
3.671875
4
#python 3 def diz(d): sifir = [] kalanlar = list() for i in d : if i == 0 : sifir.append(i) else : kalanlar.append(i) sonuc = sifir + kalanlar return (sonuc) test = [0,2,5,8,6,0,0,7] d = diz(test) print(d)
331477627dd5cb9e6b13f3cea75fcde810995f99
chuymtz/python_scripts
/projects/dice/dice.py
653
4
4
#from random import randint import random def roll_dice(n): random_number = random.randint(1,6) print("\nYou have rolled a {}.\n".format(random_number)) main_menu() def dice_menu(): print('\nEnter the number of dice.\n') num_dice = int(input('> ')) roll_dice(num_dice) def main_menu(): print('Type \'q\' to qu...
840a3f299777461bebbeb0a1951ab7a119ad7a26
chuymtz/python_scripts
/spyder_scripts/jan_workshop/so3.py
3,672
4.03125
4
# -*- coding: utf-8 -*- """ Python Workshop 01/30/2015 Exercise 3 Execute the first line of code, which generates a variable "seq", which is a DNA sequence 1. Count the number of 'C's in the sequence and print it out 2. Calculate its 'GC-content' and print it out GC-content = (#G + #C) / sequence lengt...
6473549df86b8ce3c0f09603cf4e97346bddae14
viticlick/adventofcode
/2020/day_07/day_07_02.py
691
3.578125
4
#! /usr/bin/env python3 import re, sys def bags(colorset, color): if colorset.get(color) == []: print(color, ' has no bags inside') return 1 print(color, ' contains:') counter = 0 for n, c in colorset[color]: counter = counter + int(n) * bags(colorset,c) print(n, ' of ...
c36cca80b50214006b35ce064e0a0756942482cc
viticlick/adventofcode
/2020/day_12/day_12.py
1,015
3.890625
4
#! /usr/bin/env python3 import re class Ship(): def __init__(self): self.compass = ['N','E','S','W'] self.facing_to = 1 self.position = { "N" : 0, "S" : 0, "E" : 0, "W" : 0 } def move(self, action, value): if action...
b6dc70544dbe6a2e3b7021d04355016b31d8bb9d
robertwuss/PythonCodeClass
/is5.py
94
3.828125
4
msg = input() a = msg if a == 5: print('this is 5') else: print ('this is not 5')
c2eb7abdf2b4313193163c0cfdaaa365dbb393cf
nightwatch92/HackBulgaria-Programming101-exercises
/week0/number_to_list/solution.py
134
3.53125
4
def number_to_list(n): n = abs(n) n = str(n) list = [] for digit in n: list.append(int(digit)) return list
bafe4c604c5539a31dcb02c6a32b82c9889ab17c
nightwatch92/HackBulgaria-Programming101-exercises
/week0/number_balanced/solution.py
693
3.65625
4
def is_number_balanced(n): to_str = str(n) lenght = len(to_str) first_part = to_str[:len(to_str)//2] second_part = to_str[len(to_str)//2:] # print(first_part, second_part, third_part) left_part = 0 for x in first_part: left_part += int(x) # print(left_part) right_part = ...
1dfcf6225ea686ebf66f46d924731b1843663e23
nightwatch92/HackBulgaria-Programming101-exercises
/week0/sum_of_divisors/solution.py
350
3.78125
4
def sum_of_divisors(n): index = 1 result = 0 while index <= abs(n): if n % index == 0 : result = result + index index = index + 1 return result def main(): print(sum_of_divisors(8)) print(sum_of_divisors(3)) print(sum_of_divisors(1)) print(sum_of_divisors(1000)) print(sum_of_divisors(7)) if _...
b29b31927a4973b2413236b24fb5ba41f5bd6542
nightwatch92/HackBulgaria-Programming101-exercises
/week0/biggest_difference/test.py
936
3.515625
4
import unittest import solution class BiggestDifferenceTest(unittest.TestCase): """docstring for VowelsTest""" def test_biggest_difference(self): self.assertEqual(-99,solution.biggest_diffarance(range(100))) self.assertEqual(0,solution.biggest_diffarance([1,1,1,1])) self.assertEqual(0,s...
c6df0cd4a9ef708fee71ed7da66569f64b339e02
nightwatch92/HackBulgaria-Programming101-exercises
/week0/is_int_palindrom/test.py
1,259
3.515625
4
import unittest import solution class IsIntPalindrom(unittest.TestCase): """docstring for SumOfDivisorsTest""" def test_is_palindrom(self): self.assertEqual(False, solution.is_int_palindrom(889)) self.assertEqual(True, solution.is_int_palindrom(101)) def test_zero_palindrom(self): ...
95e2755f031e25873023a3ddef573d4375da9fef
nightwatch92/HackBulgaria-Programming101-exercises
/week0/prime_factorization/solution.py
884
3.578125
4
def prime_factorization(n): primfac = [] d = 2 while d*d <= n: while (n % d) == 0: primfac.append(d) n //= d d += 1 if n > 1: primfac.append(n) f = [primfac.count(el) for el in primfac] if len(primfac) == 1: first_value1 = primfac...
a2a917cc460652648c7d1a1e63acea8bc3a87725
ChrisToumanian/wave-fitter
/combine.py
432
3.640625
4
#! /usr/local/bin/python3 import sys import math def main(): pairs = {} # combine for i in range(1, len(sys.argv)): f = open(sys.argv[i], 'r') lines = f.readlines() for line in lines: x = float(line.split(' ')[0]) y = float(line.split(' ')[1]) if str(x) in pairs: pairs[str(x)] += float(pai...
45c58c6fe36db189aae6da06ae0d76e648a589cd
lianbo2006/Project
/test/python/Day 1: Data Types.py
506
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- i = 4 d = 4.0 s = 'HackerRank ' # Declare second integer, double, and String variables. # Read and save an integer, double, and String to your variables. n=int(input()) o=float(input()) s1=input().strip() # Print the sum of both integer variables on a new line. print(i+n) ...
bfeff7606be263b858c5ff1881f3831b4b8b7664
andersonwillsam/Will_OS
/Will_OS_Files/WillGames/Baseball/Functions.py
1,615
3.578125
4
import time import math def wait(): # Change both wait times to 0 for game to complete immediately time.sleep(2) # default 2 def wait_short(): time.sleep(.5) # default .5 def batting_team(half_inning): if half_inning % 2 == 0: return "home" else: return "away" def pitching_team(half_inning): if half_inn...
2f9b70942f1005798c09f0a3f4e95bc6ea681c0e
bourov/translator
/Problems (10)/What day is it/main.py
140
3.59375
4
offset = int(input()) if offset + 10.5 >= 24: print('Wednesday') elif offset + 10.5 < 0: print('Monday') else: print('Tuesday')
c72386586f7fb7b7d66a281485e43b050f82bfd2
bourov/translator
/Problems (30)/Plurals/main.py
123
3.984375
4
number = int(input()) word = input() # write a condition for plurals print(number, word if number == 1 else word + 's')
72145292859d6d1fb0d8f84e0c0adf4550966733
voidnologo/coursera
/principles_of_computing_1/2048/cli_2048_main.py
1,850
3.703125
4
import cmd from cli_2048 import Game class GameLoop(cmd.Cmd): welcome = "Command Line 2048 " prompt = '>>> ' def preloop(self): print(self.welcome) self.initialize_game() def initialize_game(self): default = (4, 4) size = input('What size of game board do you want? ...
7c8a0bd5accb2abec67a3501e521ec330efa17cf
littlew/CellPAD
/CellPAD/pipeline/filter.py
11,260
3.90625
4
# Copyright (c) 2017 Wu Jun (littlewj187@gmail.com) import numpy as np class DropAnomalyFilter: def __init__(self, rule='gauss', coef=2.5): """ DropAnomalyFilter is a class for measuring the drop degree. DropAnomalyFilter implements three anomaly detection methods, - gau...
f453d9cf5dce7a5cf043d16c53fb4e0c75914463
HaithamAsaad/Python-V2
/Part A TempConv/temperature converter.py
779
3.796875
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 23 13:48:31 2018 @author: haithama """ Fflg=0; Cflg=0; x = int(input("input temerature mode 1 for C to F and 2 for F to C ")) T = int(input("input temerature ")) if x==1: Fflg=1; F = ((T + 40)* 9/5) - 40 print("temperature in F is ",F) elif x==2: Cflg=1; ...
b5bde237775df9410b4778b58235a56007c55427
sgriffith3/try2Go
/class_link.py
394
3.546875
4
def class_html(): course_name = input("Course Name: ") labs = input("Number of Labs: ") low_student_number = input("Lowest Student ID Number: ") high_student_number = input("Highest Student ID Number: ") print("Your Class Link is http://alta3.com/graphs?={}&={}&={}&={}".format( cou...
c86e7a38823aefed6fee9ba5f180c30ea35157d8
6895mahfuzgit/Calculus_for_Machine_Learning
/delta_method_practise.py
427
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 1 22:59:11 2021 @author: Mahfuz_Shazol """ import numpy as np import matplotlib.pyplot as plt x=np.linspace(-10,10,1000) #function y=x^2+2x+2 def f(x): x=x**2+2*x+2 return x x_delta=0.000001 x=-1 #find the slop of x=-1 y=f(x) print('y:',y) #the point P i...
6f2f358e0f5ce0f1e9ceb33e63d1da37adbb731b
cog/Shuffle-Tracker
/shuffle_tracker/shuffle_tracker.py
1,222
3.765625
4
# -*- coding: utf-8 -*- """Track cards through shuffles and cuts""" CARDS = ['AH', '2H', '3H', '4H', '5H', '6H', '7H', '8H', '9H', '10H', 'JH', 'QH', 'KH', 'AC', '2C', '3C', '4C', '5C', '6C', '7C', '8C', '9C', '10C', 'JC', 'QC', 'KC', 'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D',...
da8f3be8b7da919b7ea537bbc55817439fc6d700
ankitoct/Core-Python-Code
/1. Variable and Operators/10. isNotOperator.py
66
3.71875
4
a = 10 b = 10 print(a is not b) a = 10 b = '10' print(a is not b)
3061d9515b321d746e69674f44b9550ae0e6f151
ankitoct/Core-Python-Code
/40. List/6. AppendMethod.py
222
4.125
4
# Append Method a = [10, 20, -50, 21.3, 'Geekyshows'] print("Before Appending:") for element in a: print (element) # Appending an element a.append(100) print() print("After Appending") for element in a: print (element)
52ffb75abd2f29ecbedc9835433a3b441243d6a4
ankitoct/Core-Python-Code
/1. Variable and Operators/8. notInOperator.py
164
3.515625
4
st1 = "Welcome to geekyshows" print("subs" not in st1) st2 = "Welcome to geekyshows" print("to" not in st2) st3 = "Welcome top geekyshows" print("to" not in st3)
749d22c7b3be00f25f1f604928937450ecf873d6
ankitoct/Core-Python-Code
/58. Important Function/8. dictFunction.py
149
3.515625
4
# dict() Function a = [(101, 'Rahul'), (102, 'Raj'), (103, 'Sonam')] print(a) print(type(a)) new_a = dict(a) print(new_a) print(type(new_a)) print()
e7902135af7f4199590e50467ebecb9b6aa82685
ankitoct/Core-Python-Code
/29. Numpy Two D ones Function/1. TwoDOnesFunction.py
634
4.03125
4
# 2D Array using ones Function Numpy from numpy import * a = ones((3,2), dtype=int) print("**** Accessing Individual Elements ****") print(a[0][0]) print(a[0][1]) print(a[1][0]) print(a[1][1]) print(a[2][0]) print(a[2][1]) print() print("**** Accessing by For Loop ****") for r in a: for c in r: print(c) print() ...
bd44616f212df95e3ac53792dc0c506dca28d64d
ankitoct/Core-Python-Code
/10. While Loop/2. whileElseLoop.py
138
4
4
# While Else Loop a = 1 while a<=10: print(a) a+=1 else: print("While Condition FALSE So Else Part Executed") print("Rest of the Code")
0a064e70245373690e15b0a00b36ee1f2ba76c8d
ankitoct/Core-Python-Code
/45. Tuple/6. tupleModification.py
585
4.125
4
# Modifying Tuple a = (10, 20, -50, 21.3, 'GeekyShows') print(a) print() # Not Possible to Modify like below line #a[1] = 40 # Show TypeError # It is not possible to modify a tuple but we can concate or slice # to achieve desired tuple # By concatenation print("Modification by Concatenation") b = (40, 50) tup1 = a...
0bd0d5d36b1b20c75b521a6fa1b77bfd32931af0
ankitoct/Core-Python-Code
/26. Numpy Input From User 1D Array/2. gettingInputFromUser1DArrayWhileLoop.py
291
3.765625
4
# Getting Input from user in 1D Array using While Loop Numpy from numpy import * n = int(input("Enter Number of Elements: ")) a = zeros(n, dtype=int) u = len(a) i = 0 j = 0 while(i<u): x = int(input("Enter Element: ")) a[i] = x i+=1 while(j<(len(a))): print(a[j]) j+=1 print(type(a))
54051160251db27cf67af23632cac19a82b6c411
ankitoct/Core-Python-Code
/40. List/5. DeletionList.py
257
3.75
4
a = [10, 20, -50, 21.3, 'Geekyshows'] print("Before Deletion: ") print(a) print() # Deleting single element of List print("After Deletion:") del a[2] print(a) print() # Deleting entire List del a print(a) # It will show error as List a has been deleted
771338ef5b59bece23ddf67331ac5824bbcc0cde
ankitoct/Core-Python-Code
/16. Numpy One D Array Function/1. arrayfunction.py
1,576
4
4
# 1D Array using array Function Numpy Example 1 import numpy stu_roll = numpy.array([101, 102, 103, 104, 105]) print(stu_roll) print(stu_roll.dtype) print(stu_roll[0]) print(stu_roll[1]) print(stu_roll[2]) print(stu_roll[3]) print(stu_roll[4]) # 1D Array with Float Number using array Function Numpy Example 2 import nu...
a673f44d42f7a6ee67fa74814afac52099634358
ankitoct/Core-Python-Code
/38. Function/28. TwoDecoratorFunction.py
642
4.1875
4
# Two Decorator Function to same function # Example 1 def decor(fun): def inner(): a = fun() add = a + 5 return add return inner def decor1(fun): def inner(): b = fun() multi = b * 5 return multi return inner def num(): return 10 result_fun = decor(decor1(num)) print(result_fun()) # Example 2 de...
5137a5b00a1198a7ff7878824fda595e36ce314e
ankitoct/Core-Python-Code
/52. Dictionary/2. ModifyingDict.py
223
3.671875
4
# Modifying Dictionary stu = {101: 'Rahul', 102: 'Raj', 103: 'Sonam' } print("Before Modification:") print(stu) print(id(stu)) print() stu[102] = 'Python' print("After Modification:") print(stu) print(id(stu)) print()
4a5c283937a23193f3f0cf9e9a3eb11994c7b3c3
ankitoct/Core-Python-Code
/40. List/9. insertMethod.py
156
3.796875
4
#insert() Method a = [10, 20, 30, 10, 90, 'Geekyshows'] print("Before:",a) a.insert(3, 'Subscribe') print("After:",a) for element in a: print (element)
f341356d382ea355f3402d2f1e2be8960b9cd081
ankitoct/Core-Python-Code
/15. Array/5. insertMethod.py
278
3.59375
4
# Insert from array import * stu_roll = array('i', [101, 102, 103, 104, 105]) n = len(stu_roll) i = 0 while(i<n): print(stu_roll[i]) i+=1 print("Array After Insert") stu_roll.insert(1, 106) stu_roll.insert(3, 107) n = len(stu_roll) i = 0 while(i<n): print(stu_roll[i]) i+=1
74b872c0cdaec66aa6e378aed100b87079b91f6d
ankitoct/Core-Python-Code
/54. Nested Dictionary/3. AccessNestedDict1.py
375
4.40625
4
# Accessing Nested Dictionary using For loop a = {1: {'course': 'Python', 'fees':15000}, 2: {'course': 'JavaScript', 'fees': 10000 } } # Accessing ID print("ID:") for id in a: print(id) print() # Accessing each id keys for id in a: for k in a[id]: print(k) print() # Accessing each id keys -- value for id in...
fba5066edb3916f2d8eec8ca5ab564335c6cdbf9
ankitoct/Core-Python-Code
/58. Important Function/7. setFunction.py
425
3.703125
4
# set() Function a = [10,20,30] print(a) print(type(a)) new_a = set(a) print(new_a) print(type(new_a)) print() b = (10,20,30) print(b) print(type(b)) new_b = set(b) print(new_b) print(type(new_b)) print() c = "GeekyShows" print(c) print(type(c)) new_c = set(c) print(new_c) print(type(new_c)) print() d = {101:'Rahul'...
bbf0d85066f85fae9f77a1a91d43237aaa3a1f57
ankitoct/Core-Python-Code
/9. if elif else Statement/1. ifelifelseStatement.py
472
4.40625
4
# If elif else Statement day = "Tuesday" if (day == "Monday"): print("Today is Monday") elif (day == "Tuesday"): print("Today is Tuesday") elif (day == "Wednesday"): print("Today is Wednesday") else: print("Today is Holiday") # If elif else with User Input day = input("Enter Day: ") if day == "Monday": print("To...
ec9e9c5652c7abebb904349d0f33c50e058ca9a0
ankitoct/Core-Python-Code
/37. String Functions/7. Example7.py
221
3.78125
4
print("****** startswith Function ******") name = "Hi How are you" str1 = name.startswith('Hi') print(name) print(str1) print("****** endswith Function ******") name = "Thank you Bye" str1 = name.endswith('Bye') print(name) print(str1)
7457008cab91ec66f819dcaec3f2b4bd4e69c627
ankitoct/Core-Python-Code
/36. Formatting String/7. FStringExample3.py
897
4.125
4
# Thousand Separator price = 1234567890 print(f"{price:,}") print(f"{price:_}") #Variable name = "Rahul" age= 62 print(f"My name is {name} and age {age}") # Expression print(f"{10*8}") # Expressing a Percentage a = 50 b = 3 print(f"{a/b:.2%}") # Accessing arguments items value = (10, 20) print(f"{value[0]} {value[1...
9e3c71a9e4df068f7e4982ec9d335abb08f0d796
ankitoct/Core-Python-Code
/40. List/10. popMethod.py
148
3.84375
4
#pop() method a = [10, 20, 30, 10, 90, 'Geekyshows'] print("Before POP:", a) a.pop() print("After POP:", a) for element in a: print(element)
d6a56cdb7c1ced567dce8514c33969fb00559086
ankitoct/Core-Python-Code
/55. List Comprehension/3. ListCompNestedConditional.py
252
4.03125
4
# List Comprehension # Without List Comprehension (Conditional) lst1 =[] for i in range(20): if(i%2==0): if(i%3==0): lst1.append(i) print(lst1) # With List Comprehension (Conditional) lst2 =[i for i in range(20) if i%2==0 if i%3==0] print(lst2)
50e73325ec725a44435d6436bddcda31b9a40578
renatodjurdjevic/petlje
/while-petlja-primjer.py
414
3.578125
4
# while petlja import random # importamo random library secret = random.randint(1,30) while True: guess = int(input("Pogodi jedan broj izmedju 1 i 30: ")) if guess == secret: print("Bravo! Traženi broj je bio: " + str(secret)) break elif guess > secret: print("Fulao si, probaj s...
3a3484608d9f4df11ef21c158fb0b2021f36c069
PaliwalSparsh/Attendance-Project
/func.py
1,626
3.515625
4
#!usr/env/bin/python2.7 import sqlite3 import datetime def take_attendance(strength,course,conn_obj): today = str(datetime.date.today()) print ("Attendance for %s" %today) try: conn_obj.execute("ALTER TABLE %s ADD COLUMN '%s' 'char'" %(course,today)) except sqlite3.OperationalError: print "Attendance for the...
7db324b896ba06a565b38640bcc16512f23ee7c0
HarshPraharaj/LeetcodePractice
/Easy/1365_HowManyNumbersAreSmallerThantheCurrentNumber.py
331
3.59375
4
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: dict1 = {} n = nums[:] nums.sort() for i in range(len(nums)): if i == 0 or nums[i-1] < nums[i]: dict1[nums[i]] = i return [dict1[num] for...
a60165af0986981ea6097e34278a844d9b9b2f70
MirandaTowne/Python-Projects
/grade_list.py
754
4.46875
4
# Name: Miranda Towne # Description: Creating a menu that gives user 3 choices # Empty list grade = [] done = False new_grade = '' # Menu options menu = """ Grade Book 0: Exit 1: Display a sorted list of grades 2: Add a grade to the list """ # Display menu at start of a while loop while not done: ...
b58755aca2047658a8d56dfcb65258e2789d4f26
PashaKlybik/Python
/lab2/z4.py
3,498
3.625
4
__author__ = 'pasha' class Vector(): def __init__(self,n=1): self.vec = [0 for _ in range(n)] def __len__(self): return len(self.vec) def __getitem__(self, item): if 0<=item<len(self.vec): return self.vec[item] return None def __setitem__(self, key, value)...
c44a238b0c36f6f4d1e74ec2b3de0fe7d18b0d3f
Inerial/leetcode
/8_30/2.py
670
3.6875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: root = head = ListNode(0) extra = 0 while l1 or ...
37d959edf740464ebade95b257fdc78945b2a1d9
shubhamgg1997/pyspark
/excersise/list.py
262
3.546875
4
'''Write a program which take a list of list and give result of # all list''' from pyspark import SparkContext sc = SparkContext("local", "list app") list1=[[1,2,3],[4,5,6],[7,8,9]] list2=sc.parallelize(list1) list3=list2.reduce(lambda x,y: x+y) print(list3)
11720d7839d3f1452e70e42a73a1a2e508b4b56e
AurelienCaille/ProjetGraphes
/CarteDestination.py
461
3.9375
4
class CarteDestination(object): """ Class representant une carte destination du jeu """ def __init__(self, depart, arrive, point): """ :attribut self.depart: def self.depart to depart :attribut self.arrive: def self.depart to arrive """ self.depart = depart self.a...
7a64cd8c0aca172f6f0fe660c19bcf62451000be
kimalaacer/Head-First-Learn-to-Code
/chapter 4/thing1.py
266
3.5625
4
characters=['a','m','a','n','a','p','l','a','n','a','c'] output='' length=len(characters) i=0 while(i<length): output=output+characters[i] i=i+1 length=length * -1 i=-2 while(i>=length): output=output+characters[i] i=i-1 print(output)
ec40f68419b2a7c639bb9614cf1447f02927f529
kimalaacer/Head-First-Learn-to-Code
/chapter 12/dog4.py
1,205
4.34375
4
# this is an introduction to object oriented programming OOP # dog class has some attributes (state) such as name, age, weight,and behavior ( or method) bark class Dog: def __init__(self, name, age, weight): self.name = name self.age = age self.weight = weight def bark(self): ...
78f5290978cd8434f697f538acf29cab1797430d
kimalaacer/Head-First-Learn-to-Code
/chapter 9/crazy_sys_argv.py
1,946
3.765625
4
# this code is for a game crazy lib import sys def make_crazy_lib(filename): try: file=open(filename, 'r') text='' for line in file: text=text+process_line(line) file.close() return text except FileNotFoundError: print("Sorry, Coul...
ba44dedf1532fe9b0242830580ad7cf930354e50
kimalaacer/Head-First-Learn-to-Code
/chapter 11/blastoff.py
367
3.671875
4
# using tkinter to update root at 1000 ms from tkinter import * root = Tk() count = 10 def countdown(): global root, count if count > 0: print (count) count = count -1 root.after(1000, countdown) # this is using the after module in tkinter to autoupdate else: ...
d1ea9bede4e582981025d41bfb63994aa3bee27d
kimalaacer/Head-First-Learn-to-Code
/chapter 5/compute.py
160
3.71875
4
def compute(x,y): total= x+y if total>10: total=10 return total test1=compute(2,3) test2=compute(11,3) print(test1) print(test2)
c88afb04db70df72b71e62a667d5734b502679e2
kimalaacer/Head-First-Learn-to-Code
/chapter 6/readability.py
2,729
4.03125
4
# this code is to check the readability of ch1 text #f=open('ch6.txt','r') #contents=f.read() #print(contents) import ch1_text def count_syllables(words): count =0 for word in words: word_count=count_syllables_in_word(word) count=count+word_count return count def count_syllables...
a1888d6249afb09d877a7dead579d416487cbe57
oomintrixx/EC500-hackthon
/sqlite_database/serverTable3_db.py
2,364
4
4
import sqlite3 #server table three: table used for store online_users #primary ID, username(string), ip address(string), port(int), public key(string) def server_database3(): conn = sqlite3.connect('server_table3.db') #Opens Connection to SQLite database file. conn.cursor().execute('''CREATE TABLE server_tabl...
644c69d138019c8b1230cba53f6368508a250e8f
mmilett14/project-euler
/8-largest-product-in-a-series.py
404
3.515625
4
# Use sliding Window # Solved problem window_max = 0 i = 0 for i in range(0, len(num)-12): window_prod = int(num[i]) * int(num[i+1]) * int(num[i+2]) * int(num[i+3]) * int(num[i+4]) * int(num[i+5]) * int(num[i+6]) * int(num[i+7]) * int(num[i+8]) * int(num[i+9]) * int(num[i+10]) * int(num[i+11]) * int(num[i+12]) ...
a2812dfad727e073118a0a5fac2df8d4d771618c
alem-classroom/student-python-introduction-AubakirovArman
/sets/sets.py
436
3.75
4
def size_of_set(set): return len(set) def is_elem_in_set(set, elem): return elem in set def are_sets_equal(first_set, second_set): return first_set==second_set def add_elem_to_set(set, elem): set.add(elem) return set def remove_elem_if_exists(set, elem): if elem in set: set.remove(ele...
6e7d6ba858aabbe11f058f94ca79ed004191a036
sarsaparel/lesson2
/Documents/projects/lesson2/if1.py
354
4
4
age = int(input('Сколько тебе лет? ')) if age < 5: print ('Кушай манную кашу с комочками') elif 5 <= age <= 16: print ('Заполни дневник, играй в CS') elif 16 < age <= 21: print ('Пиши курсовую') elif age > 21 : print ('Ешь печеньки, получай зарплату')
bf779d5b46eb8ec609bc3f5159b40364cfc85c20
sychaichangkun/Udacity_Courses
/CS212:Design of Computer Programs/Lesson4/Csuccessors.py
2,586
3.859375
4
# ----------------- # User Instructions # # Write a function, csuccessors, that takes a state (as defined below) # as input and returns a dictionary of {state:action} pairs. # # A state is a tuple with six entries: (M1, C1, B1, M2, C2, B2), where # M1 means 'number of missionaries on the left side.' # # An action i...
0c0ee41359c913d08ad4c33914a13e99f85a054a
Silentsoul04/2020-02-24-full-stack-night
/1 Python/solutions/random_password.py
1,114
3.875
4
import random import string def get_lowercase_letters(n_letters, password): for i in range(0, n_letters): password.append(random.choice(string.ascii_lowercase)) def get_uppercase_letters(n_letters, password): for i in range(0, n_letters): password.append(random.choice(string.ascii_uppercase))...
bffb8076b777e4962c687e0f9c790b5fafc93041
Silentsoul04/2020-02-24-full-stack-night
/1 Python/solutions/unit_converter.py
697
4.25
4
def convert_units(data): conversion_factors = { 'ft': 0.3048, 'mi': 1609.34, 'm': 1, 'km': 1000, 'yd': 0.9144, 'in': 0.0254, } value, unit_from, unit_to = data converted_m = conversion_factors[unit_from] * value return round(converted_m / conversi...
f9bd9368cf0fbb371e9549eed41bfe1ece94a20b
vxrnxk/python-brasil-exercicios-estrutura-de-decisao
/L02-E06.py
794
4.0625
4
# Lista 02 - Exercício 06 # Faça um Programa que leia três números e mostre o maior deles. primeiro_numero = int(input("Digite o primeiro número ")) segundo_numero = int(input("Digite o segundo número ")) terceiro_numero = int(input("Digite o terceiro número ")) maior_numero = 0 if primeiro_numero > segundo_numero: ...
4522bc7692b2ae528cdc1a18b1c7d00c47ca808c
sagarwani/simple_Programs
/MovingAverage.py
1,558
4.0625
4
#Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. # #Example: # #MovingAverage m = new MovingAverage(3); #m.next(1) = 1 #m.next(10) = (1 + 10) / 2 #m.next(3) = (1 + 10 + 3) / 3 #m.next(5) = (10 + 3 + 5) / 3 class MovingAverage(object): def __init__(...
7960c0c29c9870b0edae9256f45e6cd8c22d0336
wilmtang/PythonBasicKnowledge
/尾递归的阶乘.py
176
3.875
4
def fact(n): return fact_iter(n, 1) def fact_iter(n, product): if n==1: return product else: return fact_iter(n-1, product*n) n=7 print('fact(%d) =%d' % (n, fact(n)) )
268877ac74d3f32b7e8a49dba2228bf29fdf9742
Mukul-12/tuple
/tuple4.py
94
3.6875
4
t=eval(input('enter your list : ')) m=eval(tuple(input('enter your list : '))) a=t+m print(a)
d17ae00557886fec698e222a49805cce5af9ffa4
hirangoly/PythonExercises
/lcm.py
176
3.640625
4
from sys import argv def lcm(x,y): tmp=x while (tmp%y)!=0: tmp+=x return tmp def lcmm(*args): return reduce(lcm,args) args=map(int,argv[1:]) print lcmm(*args)
3adafc3efa2519a2d272a00013c70b0aa3983fb3
CS-Cowboy/HRSolutions
/dp_ksack/solve_equal_subset_partition.py
1,435
3.65625
4
import sys from typing import Dict targetVal = 0 nums = list() def solve_equal_subset_partition(memo, sums, n, i): K = i + 1 if i == len(nums) or sums[K] == targetVal: return memo[i] # print("new call-> ", memo, sums, n, i, '\n') for N in nums: if N == n: continue ...
ac41db90b8f4c9bc50a0d9ca61e772cde263941f
AmotzL/Spotify_Recommendation
/spotify_crawler.py
6,070
3.546875
4
import spotipy import json from spotipy.oauth2 import SpotifyClientCredentials from globs import * TRACKS_LIMIT = 500 client_credentials_manager = SpotifyClientCredentials(client_id=CLIENT_ID, client_secret=CLIENT_SECRET) sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) def playlists_by_...
18e87e4ac3bb3ee0793687214fac727e1fa5a2e8
tditrani/ChallengeProject
/twitter_search.py
575
3.75
4
#!/usr/bin/env python import twitter #Get the term to search for search_term = raw_input("Term to search for: ") #Initilize the Api with the necisary info api = twitter.Api(consumer_key='uNzYbptRPxMLQnoZ73daQuPHw', consumer_secret='NExhIi50MBCkt6bkTTK62MEAbcZcUyvBir9wK81vcCwMBen15y', ...
a055c9d02f04d0f83f37f1f0f6a6fbc52d070b42
IvanDimitrov2002/school
/tp/hw2/homework2_tests.py
5,945
3.75
4
import unittest from solution import TicTacToeBoard class TestTicTacToe(unittest.TestCase): def setUp(self): self.board = TicTacToeBoard() # # column tests def test_left_column_with_x_win(self): self.board["A1"] = "X" self.board["B2"] = "O" self.board["A2"] = "X" ...
bc6cfcaf8c2aa0d71f6afdb2b22d5200b30778da
jamesbusbee/train_script
/main.py
2,273
3.5625
4
#!/usr/bin/env python3 from bs4 import BeautifulSoup; # for web scraping import requests; import urllib.request; from urllib.request import urlopen; import re; import sys; # sets the destination URL and returns parsed webpage as BeautifulSoup object # to be used in other functions def choose_vehicle_class(choice): ...
be5b38013b9ec0fd33d940636a846def635e1bc3
wangzitiansky/Learning
/src/book-notes/effective-python/ch01/code/10.py
531
3.953125
4
# 用enumerate取代range flavor_list = ['vanilla', 'chocolate', 'pecan', 'strawberry'] for i in range(len(flavor_list)): flavor = flavor_list[i] print('%d %s' % (i + 1, flavor)) for i, flavor in enumerate(flavor_list, 1): print('%d %s' % (i, flavor)) ''' 输出均是: 1 vanilla 2 chocolate 3 pecan 4 strawberry ''' ...
e23acb78551656296d8c490bac569ae20dd1fa53
Dauflo/4AIT-Chatbot
/fake_data_generation.py
2,255
3.796875
4
import datetime import json import random def check_city(city, data): for data_city in data: if city.lower() == data_city.lower(): return True return False # Use to generate coherent fake data, in prodcution env, this would be an API call to a booking API def create_fake_data(city='', numb...
7abefc2fa401d166bc0fef096992dc4cc90ae999
QMIND-Team/Modern-OT
/wavProcessing.py
10,873
3.5625
4
# This file is no longer needed for our project, but it might be useful to keep # TODO: Consider deleting this file from pyAudioAnalysis import audioFeatureExtraction import matplotlib.pyplot as plt import os import numpy from pydub import AudioSegment def readAudioFile(path): """Reads an audio file located at s...