blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
3a0756c16a5479ac6e722d4441ba8d544a327571 | gabrieleliasdev/python-cev | /ex085.py | 578 | 4.21875 | 4 | """
Exercício Python 085
Crie um programa onde o usuário possa digitar sete valores numéricos
e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares.
No final, mostre os valores pares e ímpares em ordem crescente.
"""
lst = [[],[]]
for i in range(7):
i = int(input(f"Type... |
202271a46df6dfb4f8621313fa9accf67c8c73a5 | gabrieleliasdev/python-cev | /ex045.py | 980 | 4.09375 | 4 | """045 - Crie um programa que faça o computador jogar Jokenpô com você."""
from random import randint
from time import sleep
g = ("Scissors", "Paper", "Rock")
bot = randint(0, 2) # or bot = choice(g)
print("\nChoose between:\n[0] Scissors\n[1] Paper\n[2] Rock\n")
u = int(input(">>> "))
print("\nJO")
sleep(1)
prin... |
33dfbf2afa8807e3ff976ba0ebcf99a86a810a80 | sirvar/fast-and-furious-parking | /Car.py | 6,877 | 3.5 | 4 | #car class that has driving physics, parking, and car collision
from pygame import *
from math import *
class Car():
def __init__(self, surface, picture, x, y, angle):
"Initialize all variables and set car image, location, and angle"
self.surface = surface
self.carRect = Rect(0,0,0,0)
self.speed = 1
self.c... |
099def9b7817d58ef78f0e4a89583b62a417b304 | imanfaraji/python_codes | /practice/1_Basics.py | 370 | 3.578125 | 4 | # 1st basic program
# String concat
A = "Alice"
B = "Hello"
C = A + B + "!" * 3
print(C)
print (len(A))
print("What is your age:")
myAge = input()
print ("Your age is: " + str(myAge))
if ( not (myAge == 30) ):
print("Perfect")
elif ( myAge > 30 ):
print("Old")
else:
print ("Young")
counter=1
while (counter... |
55b25c9a6b4cd211c8d45870c4d83754f89b242a | imanfaraji/python_codes | /practice/__2_linkedlist.py | 3,478 | 4.21875 | 4 | # Link list
# define Node object
class Node:
def __init__(self, d=None, next_node=None):
self.data = d
self.next = next_node #next is of type Node
def get_data(self):
return self.data
def get_next(self):
return self.next
def set_next(self, new_node):
self.next = ... |
a206a6a4ebf9e4595745550f7f0192beb92037fe | memleak13/Experimental | /Taskpad/menu.py | 1,789 | 3.546875 | 4 | #!/usr/bin/python3
''' Right now only option 1 and 2 are supported '''
import sys
import os
import datetime
from taskpad import Tasklist, Task
class Menu:
'''Display a menu and respond to choices when run.'''
def __init__(self):
self.tasklist = Tasklist()
self.choices = {
"1": ... |
9e63c3fb0e8849ecccd7ce6ebed28739e42ba12b | NikolayVaklinov10/MIT_Algorithms_Class | /Most_Important_Algorithms/Searching_And_Sorting/QuickSort/QuickSort.py | 2,832 | 3.921875 | 4 | """
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as
pivot and partitions the given array around the picked pivot. There are many different
versions of quickSort that pick pivot in different ways.
1. Always pick first element as pivot.
2. Always pick last element as pivot (... |
36b2e1a3be3cc5466158444b309efbc9d5c2c5ac | LizethAcosta/Tareas | /Quiz8p1.py | 259 | 3.78125 | 4 | # Thais Lizeth Santos Acosta
# A01630056
# Quiz 8
def triangles (size):
for x in range (1, size+1):
print ("T"*x)
for x in range (size-1,0,-1):
print ("T"*x)
x =(int(input("Gave me one number: ")))
print ("Here is you triangle (: ")
triangles (x)
|
8d52056852cf3699fa1e52c8ce938b6cd63f1503 | LizethAcosta/Tareas | /WSQ09.py | 621 | 3.890625 | 4 | # Thais Lizeth Santos Acosta
# A01630056
# WSQ09
import sys
b= "yes"
while b == ("yes"):
num= (input("Give me a positive integer number: "))
if (num.isdigit() == False):
print ("This is not what I ask :(")
sys.exit()
else:
num=int(num)
factorial = 1
if ... |
eab297adda9bf24f3278af366daab0679fcceda0 | sipeng/Leetcode_solution | /Python/263 Ugly Number/263.py | 442 | 3.9375 | 4 | # ideas:
# - take out all the prime factors from num using while loop
# - if what is left is 1, then true, otherwise false
class Solution(object):
def isUgly(self, num):
"""
:type num: int
:rtype: bool
"""
while num>=2 and num%2==0:
num = num/2
while num... |
244b99447177d8980d4ada12d7ce50848128d9c8 | Anonymous-inception/Mini_Python_Projects | /Quadratic Equation Solver/solver.py | 474 | 3.828125 | 4 | import math
a = float(input("Enter first coefficient."))
b = float(input("Enter the second coefficient."))
c = float(input("Enter the third coefficient."))
discrim = b**2-(4*a*c)
if(discrim>0):
print("Solutions of this equstion are:")
print((-b + math.sqrt(discrim)) / (2 * a))
print((-b - math.sqrt(discr... |
e7394e1aa1b0c79be3c2a92dd78fc4797758ceeb | ParulProgrammingHub/assignment-1-SHIVANGCHANIYARA | /P4.py | 159 | 3.609375 | 4 | #Enter value in Celsius and convert it to Farhenient.
c=input("Enter Temperature in Celsius")
t=c * 1.8 + 32
print "Temperature in Fahrenheit is %s" % (t)
|
924d6a3f3cc846a4aebd79905387a3940ee91487 | hpp3/Python | /untabify.py | 391 | 3.609375 | 4 | #replaces all tabs with n spaces in a file
tabw = int(raw_input("Input tab width: "))
filename = raw_input("File to convert: ")
txt = open(filename, "r")
out = open("out_"+filename, "w")
for line in txt:
while '\t' in line:
index = line.find('\t')
line = line[:index] + (tabw - index%tabw)*' ' + li... |
e200573fe5c9ac5266e5f16453d3468fe1e103f0 | ZhaoFelix/Python3_Tutorial | /02.py | 1,099 | 4.125 | 4 | # coding=utf-8
# 类
class Student(object):
#定义类属性
name = 'Felix'
age = 23
#变量名两个下划线开头,定义私有属性,这样在类外部无法直接进行访问,类的私有方法也无法访问
__sex = 0
#定义构造方法
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.__sex = sex
#类方法
def get_sex(self):
return ... |
65dd78967adb237925b4c3f68f502fb610ed1318 | alifa-ara-heya/My-Journey-With-Python | /day_02/Python_variables.py | 1,672 | 4.3125 | 4 | #Day_2: July/29/2020
#In the name 0f Allah..
#Me: Alifa Ara Heya
Name = "Alifa Ara Heya"
Year = 2020
Country = "Bangladesh"
Identity = "Muslim"
print(Name)
print(Country)
print(Year)
print(Identity)
print("My name is", Name)
#Calculating and printing the number of days, weeks, and months in 27 years:
days_in_27_year... |
73465c62f71a8a0a5b83eab5bba074212aa322c3 | alifa-ara-heya/My-Journey-With-Python | /day_14/exercise7.py | 1,011 | 4.28125 | 4 | # Day_14: August/10/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# Chapter:4 (Functions)
# Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following... |
38d16d0908fcbcde5f9aa9a8131fe3691efcee40 | alifa-ara-heya/My-Journey-With-Python | /day_33/reg_expressions.py | 1,885 | 4.59375 | 5 | # bismillah
# Book: python for everybody (chapter: 11)
# Regular Expressions
# Search for lines that contain 'From':
import re
hand = open('.\day_28\mbox-short.txt')
for line in hand:
line = line.rstrip()
if re.search('From:', line):
print(line)
'''output:
From: stephen.marquard@uct.ac.za
From: louis... |
a539280bdfe1cfc44ba252761ce0764502ba7382 | alifa-ara-heya/My-Journey-With-Python | /day_11/Exercises_on_lists.py | 7,893 | 4.5625 | 5 | # Day_11: August/07/2020
# In the name 0f Allah..
# Me: Alifa Ara Heya
# From: Book : Python Crash Course
# Chapter 3 and 4: Introducing lists and Working with lists (Exercises)
# 3-8. Seeing the World: Think of at least five places in the world you’d like to visit.
# • Store the locations in a list. Make sure the lis... |
9d4b2c3d93bf55c9acddd48195c682654fc54c48 | alifa-ara-heya/My-Journey-With-Python | /day_18/person_dict_if.py | 1,813 | 4.03125 | 4 | # Day_18: August/14/2020
# In the name 0f Allah..
# Me: Alifa
# From: 30 Days of Python by Asabeneh (Day: 9 {conditionals})
# exercises
# 7. Here we have a person dictionary. Feel free to modify it!
person = {
'first_name': 'Fatima',
'last_name': 'Zahrah',
'age': 250,
'country': 'Finland',
'is_marr... |
e4155a0fa59fa588bf3efd330f0ceb166df51c75 | alifa-ara-heya/My-Journey-With-Python | /day_20/alien_dictionary.py | 4,505 | 4.34375 | 4 | # Day_20: August/16/2020
# In the name 0f Allah..
# Me: Alifa
# Python Crash Course by Eric Matthes (Chapter: 6 [Dictionaries])
alien_0 = {'color' : 'green', 'points' : 5}
print(alien_0['color']) # green
print(alien_0['points']) # 5
new_points = alien_0['points']
print('You just earned ' + str(new_po... |
9d3f67cf1ab645c4d5744187c8d53ac6f84df0a6 | alifa-ara-heya/My-Journey-With-Python | /day_03/formatting_strings.py | 1,864 | 4.375 | 4 | #Topic: Formatting strings and processing user input & String interpolation:
#Day_2: July/30/2020
#In the name 0f Allah..
#Me: Alifa Ara Heya
print("Nikita is 24 years old.")
print("{} is {} years old".format("John", 24))
print("My name is {}.".format("Alifa"))
output="{} is {} years old, and {} works as a {}." ... |
4fe2d1fece511b56dc3851f01a2119b4b7575ac7 | alifa-ara-heya/My-Journey-With-Python | /day_14/exercise6.py | 1,372 | 4.34375 | 4 | # Day_14: August/10/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# Chapter:4 (Functions)
# Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked abov... |
1c6b11c96f7f9afb0f6ce92883e0433e78f37042 | alifa-ara-heya/My-Journey-With-Python | /day_13/coditional_execution.py | 2,354 | 4.53125 | 5 | # Day_13: August/09/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# chapter: 3
# Conditional operator:
print("x" == "y") # False
n = 18
print(n % 2 == 0 or n % 3 == 0) # True (the number is divisible by both 2 and 3)
x = 4
y = 5
print(x > y) # False
print(not x > y) ... |
41d0b8d142d9ea8e9498580dd90ecb77c5fa79f1 | alifa-ara-heya/My-Journey-With-Python | /day_30/m.py | 220 | 3.859375 | 4 | stuff = dict()
print(stuff.get('candy',-1)) # -1
x = { 'chuck' : 1 , 'fred' : 42, 'jan': 100}
y = x.items()
print(y)
print('big' > 'small')
print(11 % 5)
def sum(x, y):
return(x+y)
print(sum(sum(1,2), sum(3,4))) |
ebfe1976b54c596ca0e4a8355e26f8903e7d42a0 | alifa-ara-heya/My-Journey-With-Python | /day_13/exercise 3.1.py | 780 | 4.46875 | 4 | # 3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use in... |
c55df99c145ca4a08b9f07ba75b4b4b478f78af9 | alifa-ara-heya/My-Journey-With-Python | /day_24/loop_again.py | 1,596 | 4.09375 | 4 | # day 24
# 23- August- 2020
# sohoj vashay python
for num in range(0, 11):
print(num) # 0 1 2 3 4 5 6 7 8 9 10
# or,
num = 0
while num <= 10:
print(num)
num = num + 1 # 0 1 2 3 4 5 6 7 8 9 10
num = 0
while num <= 10:
num = num + 1
print(num) # 1 2 3 4 5 6 7 8 9 10 11
# summing 1 to 10... |
d842752a4bf06eacc6ff8f8f5f13fe6035136809 | chaydont/advent_of_code_2020 | /Day 01/day01.py | 795 | 3.53125 | 4 | import os
def part1():
memory = []
with open(os.path.dirname(__file__) + "/input.txt") as f:
for line in f:
current = int(line)
for value in memory:
if current + value == 2020:
return current * value
memory.append(current)
def par... |
b5dce366a0e6403083928c0de4eefbc26c1d654b | cajones314/avocd2019 | /src/days/day4.py | 3,055 | 3.65625 | 4 | # system
from collections import Counter
from functools import reduce
# internal
from .day import Day
"""
===============================================================================
Day 4 Puzzle 1
You arrive at the Venus fuel depot only to discover it's protected by a
password. The Elves had written the password... |
41327a468dfe75d5ef862770c98d930a62d7f2c7 | oetsps/py-test | /three-concepts/decorators/initdec.py | 1,136 | 3.796875 | 4 | # initial dec.py
from time import time
def timer(func):
def f(x, y=10):
before = time()
rv = func(x, y)
after = time()
print('elapsed', after - before)
return rv
return f
@timer
def add(x, y=10):
return x + y
# add = timer(add) => instead,... |
7fc74492d42f092d1e5a9470c9c7c04c123dcbf6 | Ch-usu/DiskToGoogleDrive | /main.py | 4,957 | 3.875 | 4 | import file_actions
import google_actions
import os
import time
from dateutil.parser import parse
from pytz import timezone
def reset_disk():
"""Writes on the csv file disk No"""
file_actions.write_csv({'disk':'No'})
def reset_folder():
"""writes on the csv file folder_name No"""
file_actions.write_c... |
7e7ee82708da027f0070e0ce8198bf7dadbed9da | udaybhaskar578/Search-and-Sorting-Algorithms | /BubbleSort.py | 779 | 4.0625 | 4 | #!/bin/python3
'''
Author: Sai Uday Bhaskar Mudivarthy
Program: Bubble Sort
Time Complexity: O(n*n)
Best Case: O(n)
Worst Case, Average Case: O(n*n)
'''
import sys
from array import *
def swap(intarray,i,imin):
temp = intarray[i]
intarray[i]=intarray[imin]
intarray[imin]=temp
n = input().strip().split(... |
c68d87cba60766441b5183dad3dbd20cd40eb7e2 | udaybhaskar578/Search-and-Sorting-Algorithms | /BinarySearchRecursive.py | 717 | 3.984375 | 4 | #!/bin/python3
'''
Author: Sai Uday Bhaskar Mudivarty
Program: Binary Search Recursive
Time Complexity: O(Log n)
'''
def BinarySearch(A,start,end,x):
if(start >end):
return -1
mid = start + int((end-start)/2)
if A[mid]==x:
return mid
elif A[mid] > x:
return BinarySearch(A,start,m... |
a2e7cd9be31324c3e7e219c8cb3645a8e519728e | dmddjack/python | /023-factorial.py | 279 | 4.0625 | 4 | def factorial_1(n, m=1):
m *= n
if n == 1 or n == 0:
return m
else:
return factorial_1(n - 1, m)
def factorial(n):
if n == 1 or n == 0:
return n
else:
return n * factorial(n-1)
print(factorial_1(998))
print(factorial(998))
|
1f2fa1e649bc54f1d014fd80c34453ed5380e9ef | ricardojuarez1999/robot | /codigo_robot.py | 787 | 3.640625 | 4 | class Robot(object):
def __init__(self, x, y):
self.x = x
self.y = y
self.rotacion = 0
self.mapa = None
self.fichas = 0
def rotar(self):
self.rotacion = (self.rotacion + 1) % 4
def dibujar(self):
if self.rotacion == 0:
return "^"
elif self.rotacion == 1:
return ">"
elif self.rotacion == 2:
... |
439c26ee1127ae5be9cb49356e83e1456f23d71c | Royalsbachl9/Web-page | /dictionary_attack.py | 726 | 4.125 | 4 | #Opens a file. You can now look at each line in the file individually with a statement like "for line in f:
f = open("dictionary.txt","r")
print("Can your password survive a dictionary attack?")
#Take input from the keyboard, storing in the variable test_password
#NOTE - You will have to use .strip() to strip whitesp... |
a7cb9254cdcf62ceda3f6a0d476edd5072df9245 | betogalvao/CAM-LGR | /jogofinal.py | 3,113 | 3.546875 | 4 | import funcoesEP2 as ep2
print('Paciência Acordeão')
print('==================')
print('Seja bem-vindo(a) ao jogo de Paciência Acordeão! O objetivo deste jogo é colocar todas as cartas em uma mesma pilha. \n')
print('Existem apenas dois movimentos possíveis: ')
print('1. Empilhar uma carta sobre a carta imediatamente... |
5df2b41f4f5575d29f65d78a89c54dd27ebafdca | jenkspt/CarND-MiniFlow | /5_forward_propagation_solution/nn.py | 1,184 | 4 | 4 | """
This script builds and runs a graph with miniflow.
There is no need to change anything to solve this quiz!
However, feel free to play with the network! Can you also
build a network that solves the equation below?
(x + y) + y
"""
from miniflow import *
x, y = Input(), Input()
f = Add(x, y)
feed_dict = {x: 10,... |
05af4409f24aa1b0be76c8e08e0d557ed543923b | bdisann/day_18_turtle_gui | /main.py | 603 | 3.96875 | 4 | from turtle import Turtle, Screen
timmy_the_arrow = Turtle()
timmy_the_arrow.color("blue")
def foward_and_right(right):
timmy_the_arrow.forward(150)
timmy_the_arrow.right(right)
def make_shape():
num = float(1)
num_shape = 2
num_deg = 360/num_shape
num_to_finish = 360/num_deg
while num... |
2a5368e3d52a0eb1c5555650999e1a3601cd5672 | Joss233/Learing-Python | /exercise/password.py | 303 | 3.90625 | 4 | # -*- coding:utf-8 -*-
import chardet
password = "2333"
i = 0
tryword = input("请输入密码:")
while i < 3:
i += 1
if tryword == password:
print("密码正确!")
break
elif i < 3:
tryword = input("密码错误,请重新输入:")
else:
exit()
|
dd5c62fd6e9019c7550e2d9b8b25f24b3efacf8e | Riddarvid/AoC19Python | /day2/Day2.py | 764 | 3.53125 | 4 | from intcode_computer.IntcodeComputer import IntcodeComputer
def part1(ints):
computer = IntcodeComputer(ints)
computer.memory[1] = 12
computer.memory[2] = 2
computer.run()
return computer.memory[0]
def part2(ints):
for noun in range(0, 100):
for verb in range(0, 100):
comp... |
16dc1000381cdf2d8be630f7ae7f7eab73a5669c | Cameron-Roy/PythonExamples | /steps2-3.py | 4,183 | 4.34375 | 4 | '''
Program: Lesson 16: Step 2 and 3
Author: Cameron Roy
Date: 2020/05/22
Description: Now create the file, and write to it values that need to be saved and read.
'''
'''
Problem: Recipie for pancakes is missing.
Needs the ingredients and then the steps, and temperature for the
cooking element. There is also a revie... |
977cdbb5e40279b4bd82965f0b14a063e0667b74 | pankajprateek/easyCloud | /pythonApp/Secure IP_Y9366_Y9288_Y9399_Y9610/define.py | 856 | 3.5625 | 4 | def rotate_left(x, n):
"Rotate x (32 bit) left n bits circularly."
return (x << n) | (x >> (32-n))
def XX(func, a, b, c, d, x, s, ac):
res = 0L
res = res + a + func(b, c, d)
res = res + x
res = res + ac
res = res & 0xffffffffL
res = rotate_left(res, s)
res = res & 0xffffffffL
... |
ac6d803d5a283d22ce0e207bf04cc2e786acf09d | yujin0719/Problem-Solving | /프로그래머스/lv2.소수 만들기.py | 355 | 3.671875 | 4 | # Level2: 소수 만들기
from itertools import combinations
def isPrime(num):
for i in range(2,int(num**0.5)+1):
if num % i == 0:
return False
return True
def solution(nums):
answer = 0
candidates = combinations(nums,3)
for c in candidates:
if isPrime(sum(c)):
answe... |
9299165fdf70eb0647b061f1b39eba30bff1b374 | yujin0719/Problem-Solving | /프로그래머스/lv2.짝지어 제거하기.py | 322 | 3.640625 | 4 | # Level2: 짝지어 제거하기
def solution(s):
s = list(reversed(list(s)))
stack = [s.pop()]
while s :
c = s.pop()
if len(stack) == 0 or stack[-1] != c :
stack.append(c)
else :
stack.pop()
if len(stack) == 0:
return 1
else :
return 0
|
3cef8db04e240b95a0d90ceb9072bc4beba8b46c | The-Daishogun/coding-exercises | /code takhfif.py | 431 | 3.90625 | 4 | import string
def ispangram(str1, alphabet=string.ascii_lowercase):
alphaset = set(alphabet)
return alphaset == set(str1)
first_line = input().split(" ")
n = int(first_line[0])
alefba = first_line[1]
codes = []
for i in range(0, n):
code_to_test = input()
codes.append(code_to_test)
for code in co... |
01bc1e3919a9b858befa8a45788974cca4dae8a4 | The-Daishogun/coding-exercises | /cubicle.py | 328 | 4.0625 | 4 | def full_line(num):
output=""
for i in range(n):
output += "*"
return output
def other_line(num):
output = "*"
for i in range(n-2):
output += " "
output += "*"
return output
n = int(input())
print(full_line(n))
for i in range(n-2):
print(other_line(n))
print(full_l... |
8405e2c10b14209ffacb63a12f459c99506bddf1 | The-Daishogun/coding-exercises | /tamrin 7,8.py | 485 | 3.546875 | 4 | #tamrin 7:
def test(argument):
print(argument)
def reverse(string):
return string[::-1]
def mirror(string):
mirrored = reverse(string)
return string+mirrored
print("Tamrin 7:")
test(reverse("happy") == "yppah")
test(reverse("Python") == "nohtyP")
test(reverse("") == "")
test(reverse("a") == "a")... |
e254083b0831a2107f31f3a1dced63696e41437f | The-Daishogun/coding-exercises | /sigma gir.py | 392 | 3.8125 | 4 | from _decimal import Decimal
def calculate(n, m):
output = 0
for i in range(-10, m + 1):
loop_result = 0
for j in range(1, n + 1):
result = (i + j) ** 3
result = Decimal(result) // Decimal(j ** 2)
loop_result += result
output += loop_result
r... |
06e012d62e89496c6156273e4cb2dd1a1526ffe0 | Gildewarz777/mapreduce | /map.py | 449 | 3.671875 | 4 | # The map function recieve the row index as the key
# and the value as the value associated to the row
# We create a new key:value couple where the key
# is the column index and the value contains the rowIndex
# with the values associated to the columnindex and the
# rowindex
def map(rowIndex,values):
columnIndex = ... |
85d0fa91e632910da3491228c3ccade9fc64e59b | paul-khouri/Flask_ReadingData_Searching_Inserting | /dbInserting.py | 726 | 3.84375 | 4 | import sqlite3
fn = "Jane"
ln = "Doe"
ad = "21 Smith Street"
sub="Karori"
pc="0000"
pho = "021 667 8934"
em="janedoe@hotmail.com"
bday="12/04/2000"
gender="Other"
bio = "Bio goes here"
def db_insert(fn, ln, ad, sub, pc, pho, em, bday, gender, bio):
conn = sqlite3.connect('memberTable.sqlite')
cur = conn.curs... |
f083a6e8eb69095789d012fdb5ccc0a089569455 | catherineraj6/Cathy_Set3 | /s3.3.py | 117 | 3.734375 | 4 | def num(list):
list = [1,2,3,4]
sum = 0;
for i in list:
sum = sum + i;
print(sum)
num(list)
|
a72e49f2e39f53de4f7c438be1e0c31b948155ce | Vignesh77/python-learning | /calc.py | 435 | 3.546875 | 4 | """
@file :calc.py
@brief : Write a program for simple arithmetic operations like
add,subtract, multiplication, division.
@author :vignesh(vignesh.nanjundan@vvdntech.in)
"""
number1 = (int)(input("Enter the first Number...\n"))
number2 = (int)(input("Enter the second Number...\n"))
print... |
e0d22fcafd6e0c8ede004ca82ae7ea77165ebc67 | Vignesh77/python-learning | /chapter3/src/list_add.py | 607 | 4.34375 | 4 | """
@file :list_add.py
@brief :Create the list and add the elements.
@author :vignesh
"""
list_len = input("Enter the length of list :")
input_list =[ ]
print "Enter the values to list"
for index in range(list_len) :
list1 = input("")
input_list.append(list1)
print input_list
print "Enter do u w... |
7912637e89dfb1d82ebc5174add649d5f8774f33 | Vignesh77/python-learning | /chapter5/src/count_lines.py | 260 | 3.75 | 4 | """
@file :count_lines.py
@brief :Write a program to count no of lines in a text file.
@author :vignesh
"""
count_line = 0
file_obj = open("hello.txt")
for line in file_obj.readline():
count_line += 1
print "No of Lines :", count_line
|
c48abf9be04d7fb8c779c33c68b4c60769dc4e78 | Vignesh77/python-learning | /chapter9/src/dict_comp.py | 317 | 3.71875 | 4 | """
@file :dict_comp.py
@brief :Create the dictionary dict_sample = {1:1, 2:2} using
dictionary comprehension
@author :vignesh
"""
def print_dict():
"""
function for creating dictionary
comprehension
"""
dict1 = {n:n for n in range(1, 11)}
print dict1
print_dict()
|
41174cad480bc64651241813b951dd539b443692 | Kyrgyzbai/itc_python | /Day2/Home_works/hw3d4.py | 3,424 | 3.59375 | 4 | #Problem1:
# Дана строка: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
# Ваша задача вывести на экран
# сколько символов содержит данная строка
text = '''Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
... |
49573d1545df1152526f9f3dc66e21fd44b4b5c9 | Kyrgyzbai/itc_python | /Day2/class_works/day12_sets_dicts.py | 4,006 | 3.796875 | 4 | # # words = 'когда интернет не работает перезагрузи компьютер. Интернет тогда заработает'
# # # # суйломдон кандайдыр бир созду таап алуу туурасында
# # print("интер" in words) # 1 способ
# # if 'интернет' in words: # бул экинчи способ
# # print('есть')
# products = ['sugar','melon']
# # print([products.count('su... |
d1a206de64fb82f79d1f7c24d6339b358d16478d | Kyrgyzbai/itc_python | /Day2/class_works/Stroka.py | 88 | 3.625 | 4 | num1 = int('enter first number')
num2 = int ('enter second number')
print (num1 + num2) |
a60af021f9d8ec029d6ec7f7b2253dff9564612a | Kyrgyzbai/itc_python | /Day2/Home_works/hw7d9.py | 4,455 | 4.09375 | 4 |
# 1. Используя while выведи на экран число от 10 до 100:
# i = 10
# while i <= 100:
# print(i)
# i += 1
# c = 10
# while c < 101:
# print(c)
# c = c + 1
# 2. С помощью while спросите у человека имя фамилию и отчество:
# Проси до тех пор пока человек не вводит свои данные
# name = ''
# fname = ''
... |
6104e54b449a79acf860b2031d97e00e8f4b0f17 | GustavoGajdeczka/IPOO | /aula8/ex9.py | 284 | 3.5 | 4 | print("== Vetor 9 ==")
index = 0
aux = 0
A = [1, 2, 4, 16, 64, 256, 512, 1024]
B = [2, 8, 32, 16, 128, 512, 2048]
C = []
aux = 0
for a in A:
C.append(a)
for b in B:
aux = 0
for c in C:
if c == b:
aux = 1
if aux == 0:
C.append(b)
print(C)
|
747e2a9cfbced55cf80d83ba8898d7509c40c605 | GustavoGajdeczka/IPOO | /aula8/ex13.py | 256 | 3.8125 | 4 | from random import randint
print("== Vetor 13 ==")
A = []
index = 0
menor = 11
while index < 10:
A.append(int(randint(0, 10)))
index += 1
for a in A:
if (menor > a):
menor = a
print(A)
print("## Menor numero da lista é: %d" % menor) |
267d9a2bc0294e4438a35359644f26518ca00639 | GustavoGajdeczka/IPOO | /aula5/ex3.py | 355 | 3.984375 | 4 | print("== Equação de Segundo Grau ==")
a = float(input("Digite o valor de A: "))
b = float(input("Digite o valor de B: "))
c = float(input("Digite o valor de C: "))
D = int (b**2) - (4*a*c)
if D < 0:
print("## Delta é negativo")
else:
x1 = (-b + D**1/2) / (2*a)
x2 = (-b - D**1/2) / (2*a)
print("## X1:... |
f9dd9f4efd7c047afe6d72ecc42a759a503b7f2e | GustavoGajdeczka/IPOO | /aula5/ex9.py | 162 | 3.9375 | 4 | print("== Aumento ==")
salario = float(input("= Informe o seu salario: R$"))
print("## O seu salario com aumento é igual a : R$", (salario / 100) * 37 + salario) |
b7d20eccd6ef6066fee9b8eda68b91d9a963e535 | GustavoGajdeczka/IPOO | /aula6/ex4.py | 166 | 3.90625 | 4 | import math
print("== Raiz Quadrada ==")
a = float(input("= Digite um numero: "))
if a > 0.0:
print("# %4.2f" % math.sqrt(a))
else:
print("# %.1f" % (a * a)) |
61fb0be29391d074ac54ee69bfd960f50f05a4df | GustavoGajdeczka/IPOO | /AVAL7 Final/ex2.py | 1,242 | 4.0625 | 4 | """ Altere a definição da classe TV abaixo, criando novos métodos, para alterar o canal da TV
e ler o canal atual.
Não é necessário criar objetos da classe TV, apenas modificar a classe
class TV:
marca = None # marca da TV (string)
polegadas = None # tamanho da TV em polegadas (inteiro)
volume = Non... |
822845801e9fc232a974280dd8067226d0ceb09c | GustavoGajdeczka/IPOO | /aula8/ex7.py | 207 | 3.796875 | 4 | print("== Vetor 7 ==")
vetor = []
index = 0
while index <= 4:
vetor.append(float(input("= Insira um numero: ")))
index += 1
index -= 1
while index >= 0:
print("## ", vetor[index])
index -= 1
|
57ae9262501609a48ee31adbd2c59f9b37b4c75d | GustavoGajdeczka/IPOO | /AVAL2/ex4.py | 313 | 3.765625 | 4 | print("== Exercicio 4 ==")
index = range(5)
A = []
B = []
C = []
for n in index:
A.append(int(input("= Insira um numero: ")))
B.append(int(input("= Insira um numero: ")))
for a in A:
C.append(a)
for a in B:
C.append(a)
print("## Lista A: ", A)
print("## Lista B: ", B)
print("## Lista C: ", C) |
3e4965e158e83764bba4a2c2c2f86e4eb5055538 | GustavoGajdeczka/IPOO | /AVAL1/ex3.py | 332 | 3.8125 | 4 | print("== Idades ==")
index = 1
maior = 0
menor = 0
while index != 0:
idade = int(input("= Insira a sua Idade: "))
if idade > 60:
maior += 1
if idade < 18:
menor += 1
if idade == 0:
index = 0
print("## %d Tem mais de 60 anos de idade" % maior)
print("## %d São menores de idade" ... |
d3b86b7af656f2fcbf08d7184c04bd0abe1fda81 | Daksh/CSE202_DBMS-Project | /pythonConnection.py | 1,233 | 4.34375 | 4 | # Proof of Concept
# A sample script to show how to use Python with MySQL
import mysql.connector as mysql
from os import system, name
def clear():
if name == 'nt': # for windows
system('cls')
else: # for mac and linux
system('clear')
def createDB():
db = mysql.connect(
host = "localhost",
user = "ro... |
b769423ba1874f1202146751959087287fcc8e07 | valdergallo/pyschool_solutions | /Tuples/remove_common_elements.py | 778 | 4.40625 | 4 | """
Remove Common Elements
======================
Write a function removeCommonElements(t1, t2) that takes in 2 tuples as arguments and returns a sorted tuple containing elements that are not found in both tuples.
Examples
>>> removeCommonElements((1,2,3,4), (3,4,5,6))
(1, 2, 5, 6)
>>> removeCommonElements(('b','a',... |
629f94f34f0aeb8b755e46bb9a10c13561214208 | Wutaotao692732757/LearnPython | /helloworld/match.py | 595 | 4.03125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import re
line = "Cats are smarter than dogs";
matchObj = re.match(r'dogs',line,re.M|re.I)
if matchObj:
print "match --> matchObj.group() : ",matchObj.group()
else:
print "No match!!"
matchObj2 = re.search(r'dogs',line, re.M|re.I)
if matchObj2:
print "search -... |
d56bbb251a76be18f9be3c6c460deafafc2009ac | shenriquebm/python-task | /OverlappingLines.py | 3,235 | 4.25 | 4 | import numbers
class Line:
"""
Class for a Line object, which contains two points x1, x2.
:param x1: The leftmost point of the line
:param x2: The rightmost point of the line
"""
def __init__(self, x1: numbers.Number, x2: numbers.Number):
"""
Creates a line from point x1 to po... |
63d11c0e40b26c71ca55cbac209df9f89c3ee31d | farhanjaved47/python | /Generators/FibonacciSequenceGenerator.py | 649 | 4.21875 | 4 | """
Farhan Javed
farhan.javed47@gmail.com
12/24/2019
Generate a Fibonacci sequence using Python generators
"""
def fibonacci(n):
print('In Fibonacci Generator')
if n == 1:
yield 1
if n == 2:
yield 1
yield 1
if n >= 3:
base_number = 1
yield base_number
ne... |
024e50507b7059222e97f4dcd2906675e2c2d53d | farhanjaved47/python | /Basics/DateTime.py | 4,128 | 4.3125 | 4 | # Date and Time functionality
"""
Farhan Javed - 11-19-2019
Date and time basic functionality code. Also includes working with Calendars.
Feel free to reach out : farhan.javed47@gmail.com
"""
from datetime import date
from datetime import datetime
from datetime import timedelta
import calendar
def main():
today... |
5ae3151b3af57dd1a27d20b323b644b6d4d75ded | farhanjaved47/python | /Basics/Classes.py | 3,494 | 4.34375 | 4 | """
Farhan Javed
farhan.javed47@gmail.com
12/05/2019
Basic functionality for creating and implementing classes in Python including Inheritance and Iterator Objects.
https://docs.python.org/3/reference/datamodel.html#special-method-names
"""
class RevStr(str): # lowercase class names are predefined classes
def __... |
4c2f2f054d45fb61f89dc3d2c2104989796b9b1a | lvah/201901python | /day13/11_反射机制小案例.py | 826 | 3.765625 | 4 | """
https://www.csdn.net/nav/newarticles
https://www.csdn.net/nav/watchers
https://www.csdn.net/nav/news
https://www.csdn.net/nav/ai
https://www.csdn.net/bbs/newarticles
https://www.csdn.net/bbs/watchers
https://www.csdn.net/bbs/news
https://www.csdn.net/bbs/ai
"""
class Web(object):
def bbs(self):
... |
631bfa95e861ea82a68cd1df874468f2acade6df | lvah/201901python | /day25/08_北美电话号码的合法性.py | 637 | 3.515625 | 4 | """
文件名: $NAME.py
日期: 25
作者: lvah
联系: xc_guofan@qq.com
代码描述:
问题描述:
北美电话的常用格式:(eg: 2703877865)
前3位: 第一位是区号以2~9开头 , 第2位是0~8, 第三位数字可任意;
中间三位数字:第一位是交换机号, 以2~9开头, 后面两位任意
最后四位数字: 数字不做限制;
pattern = r'[2-9][0-8]\d[2-9]\d\d\d\d\d\d'
"""
import re
# pattern = r'[2-9][0-8]\d[2-9]\d\d... |
f24828edaaad3bf864756f696ac7955e86e666ef | lvah/201901python | /day31/19_numpy常用的方法.py | 729 | 3.65625 | 4 | """
文件名: $NAME.py
日期: 22
作者: lvah
联系: xc_guofan@qq.com
代码描述:
"""
import numpy as np
# 将一维数组转换为3行4列的二维数组
data = np.arange(12).reshape((3, 4))
data[0, 0] = 80
print(data)
# 1. 获取最大值和最小值的位置;
# 获取当前数组里面最大值的索引;
max_item1 = np.argmax(data)
print(max_item1)
# 获取每一列的最大值对应的索引;
print(np.argmax(data, axis=0))
# 获取每一行的最大... |
a8fae7c62c1a54c18cb735e15653fe170a0b9395 | lvah/201901python | /day14/01_常见的异常.py | 1,055 | 3.921875 | 4 | """
# 什么时异常?
在程序运行过程中影响程序正常运行的内容,
# 为什么需要异常处理?
可以让你的程序更加健壮, 可以清晰的快速修复异常。
1). print(s)
NameError: name 's' is not defined
2). li = [1,2,3]
li[10]
IndexError: list index out of range
3). 10/0
ZeroDivisionError: division by zero
>>> d = dict(a=1, b=2)
>>> d
{'a': 1, 'b': 2}
>>> d['c']
Traceback (most re... |
0d75bf534001dba7fd4ba861f758f51fef50d4a2 | lvah/201901python | /day14/02_异常处理的语句.py | 1,375 | 3.625 | 4 | """
try......except... else......finally......
"""
# 普通的异常处理:
# import time
# try:
# # 如果你觉得代码可能出现问题, 那么放在try语句中, 只执行一次;
# print(s)
# # print("hello")
# except NameError as e: # 对于异常进行一个重命名;记录了异常的详细信息;
# # 可能执行一次, 也可能不执行;
# print("名称错误")
# with open("except.log", 'w') as f:
# f.writ... |
d621d912465f22abb65ba6af78e8c33dbbb0e611 | lvah/201901python | /day13/02_乌龟和鱼游戏_继承的使用.py | 4,126 | 3.9375 | 4 | """
# pygame
游戏编程:按以下要求定义一个乌龟类和鱼类并尝试编写游戏
假设游戏场景为范围(x,y)为0<=x<=10,0<=y<=10
游戏生成1只乌龟和10条鱼
它们的移动方向均随机
乌龟的最大移动能力为2(它可以随机选择1还是2移动),鱼儿的最大移动能力是1
当移动到场景边缘,自动向反方向移动
乌龟初始化体力为100(上限)
乌龟每移动一次,体力消耗1
当乌龟和鱼坐标重叠,乌龟吃掉鱼,乌龟体力增加20
鱼暂不计算体力
当乌龟体力值为0(挂掉)或者鱼儿的数量为0游戏结束
"""
import random
from colorFont im... |
946df26a4d001f714996407d619e0efc5a1c124f | linseycurrie/GuessMyFavouriteColour | /precourse_recep/precourse_recap.py | 199 | 3.875 | 4 | colour = "Blue"
userGuess = input("Guess my favourite colour : ")
if userGuess.capitalize() == colour:
print("Well Done! You got it right!")
else:
print("Opps, sorry it's not " + userGuess) |
156f38da629b69973365c82d9608707915e6d28e | jeanArvel/ArvelSecurity | /ledciscospark.py | 5,505 | 3.59375 | 4 | # Import the GPIO modules to control the GPIO pins of the Raspberry Pi
import RPi.GPIO as GPIO
# Set the desired pin numbering scheme:
GPIO.setmode(GPIO.BCM)
# GPIO PIN where the LED is connected
# pin numbering based on the BCM scheme
LEDPin = 6
# Setup the direction of the GPIO pin - either INput or OUTput
GPIO.setup... |
592d80c46dff65a5cd18a75c7b3171bfe5c2c010 | rus-slm/omd | /omd.py | 4,063 | 3.640625 | 4 | # Guido van Rossum <guido@python.org>
def step1():
print(
'Утка-маляр 🦆 решила выпить зайти в бар. '
'Взять ей зонтик? ☂️'
)
option = ''
options = {'да': True, 'нет': False}
while option not in options:
print('Выберите: {}/{}'.format(*options))
option = input()
... |
4e821abd1d08746a67b9b9b4b56ee05699e4c8c5 | ramanuj760/PythonProject | /steingpelindrome.py | 162 | 3.96875 | 4 | s=input("enter string value")
l=len(s)
p=""
for i in range(l-1,-1,-1):
p=p+s[i]
print(p)
if(p==s):
print("pelindrome")
else:
print("not a pelidrome") |
8cdf06272467c226eaf008087937fbbe33a18a6e | ramanuj760/PythonProject | /l1.py | 160 | 3.796875 | 4 | """write a python program to sum all the item in a list"""
a=[25,6,19,15,34,69]
a.sort()
#print(len(a))
b=1
l=len(a)
for i in range(0,l):
b=a[i]+b
print(b)
|
d721325dd62d3047a788b98cbdc5c6d20428ed85 | ramanuj760/PythonProject | /pr srting.py | 84 | 3.6875 | 4 | a="hello"
l=len(a)
print(l)
for i in range(1,l):
b=dict(a)
print(b)
print()
|
8ebb9a939d3b9070c959fd0af7ce6e7e9c2bf723 | ramanuj760/PythonProject | /oops cl1.py | 508 | 4.125 | 4 | class A:
#print("this is a parent class")
#d={"name":"ram"}
"this is a sample string"
def __init__(self):
print("inside construcor")
def display(self):
print("inside method")
class B(A):
pass
#a is an instance of class A. A() is an object of class A
#calling a default constr... |
c2247586ff0e4aa5cfda2989927741a7c6f59da8 | ramanuj760/PythonProject | /oops self2.py | 531 | 3.796875 | 4 | class C:
def __init__(self,age=0):
self.__age=age # double under score means private and single under score are protected
#in encapsulation all member in private in nature and it contain getter and setter methods
#getter and setter method is equliproprotion no of variable in the class
#getter method
... |
e9f3b4eae9037dafc62d9b315562350e06bd39a9 | ramanuj760/PythonProject | /str1.py | 306 | 3.640625 | 4 | a="hello this is a world"
print(a.endswith("t"))
b="python"
print(b.startswith("y"))
x='python '
y='course'
z='*'.join([a,x,y])
print(z,"hkk")
print(len(a))
print(a.split("l"))
ju=a.rjust(40,"*")
lu=a.ljust(29,"/")
print(ju)
print(lu)
p='iiiiiiiikliilrn'
k=p.lstrip("i")
print(k)
j=b.rstrip()
print(j) |
e7da9efa614011db67626baed5996d06c0ba8db9 | ramanuj760/PythonProject | /pr2.py | 456 | 3.984375 | 4 | """write a python program to convert tempratures to and from celcius fahrenheit"""
print("for calculate temprature in fahrenheit press f \n calculate temrature in celcius press c")
t=input("enter f or c:")
if t=='f':
c=int(input("temp in celcius="))
f=((9*c)/5)+32
print(int(f),"f")
elif t=='c':
f= int(i... |
bf5154ef52a0f2884e9e7a1864334fd45f4f37e7 | artmukr/homework_13 | /homework_13.3.py | 1,438 | 4.03125 | 4 | # Write a decorator arg_rules that validates arguments passed to the function
# A decorator should take 3 arguments:
# max_length: 15
# type_: str
# contains: [] - list of symbols that an argument should contain
#
# If some of the rules' checks returns False, the function should return False
# and print the reas... |
68050b74f0494cc7a4beddc7084a1f264309118c | bluck90/wordsearch | /findrepeatsinsequence.py | 6,583 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 6 18:07:16 2020
@author: btgl1e14
"""
numberlist = [6,2,4,3,7,5,3,2,4,1,8,3,3,4,5,8,9,4,5,3,2,5,4,6,8,2,2,4,4,3,5,1,3,1,2,6,9,8,6,7,5,6,3,4,6,5,5,7,7,4,2,3,8,9,7,8,3,3,4,5,8,7,6,9,8,7,6,8,3,3,4,5,7]
n = 6
import pandas as pd
chakra1 = pd.read_csv('chakra1.csv', heade... |
297845ca1a3fc0719816d32e0aa30a324e404299 | Aguniec/Beginners_projects | /Fibonacci.py | 306 | 4.21875 | 4 | """
Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
"""
number = int(input("Give me a number"))
list_of_numbers = [0, 1]
for i in range(0, number):
a = list_of_numbers[-1] + list_of_numbers[-2]
list_of_numbers.append(a)
print(list_of_numbers)
|
28f439a0a623ffd4654f51d37a9fe5d5abc84f0f | Aguniec/Beginners_projects | /Reverse Word Order.py | 376 | 4.21875 | 4 | """
Write a program that asks the user for a long string containing multiple words.
Print back to the user the same string, except with the words in backwards order.
"""
def reverse_order(string):
words_to_array = string.split()
reverse_words_order = a[::-1]
return " ".join(reverse_words_order)
string... |
34bb950491c621834c91ff8ad7f136404b058d7a | Chandokyuen/Python-assignments | /timeperiod.py | 438 | 3.765625 | 4 | #the deposite amount by billy
amount_deposite=1000
#u the rate of intrest
intrest_rate=5
#the time period
time=10
#Bill money double=amount deposite
double=amount_deposite
#calculating the simple intrest
simpleintrest=amount_deposite*intrest_rate*time//100
#Time T taken to double is
T=time*double//simpleint... |
ba0bf66c366c1a195984487975f8ac734263fe52 | Prones94/Leet-Code | /vowel_removal.py | 2,534 | 4.25 | 4 | # 1. Remove Vowels From String
'''
1. Restate Problem
- Question is asking if given a string, remove all the vowels from that string 'a,e,i,o,u' and then return the string without the vowels
2. Ask Clarifying Questions
- How large is the string?
- Is there other data types as well besid... |
a0abef90eb168f28b54d7bf46f05b8f0d5194ec8 | xpaf/1st-repository | /OSC.py | 1,624 | 3.90625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
def get_data(): # Funkcja
try:
data_file_name = input("Prosze podać nazwę pliku z danymi ")
data_file = open(data_file_name)
except:
print("Błąd, zła nazwa pliku")
sys.exit(0)
vector_x = []
vector_y = []
... |
49007a030748b878f8929518237071dba2497069 | gregecho/Python | /PythonTutorial/Modules.py | 793 | 3.59375 | 4 | ####################################################
# 6. Modules
####################################################
# If you have a Python script named math.py in the same
# folder as your current script, the file math.py will
# be loaded instead of the built-in Python module.
# This happens because the local folde... |
c06c0c0efd5211e40a554d42379a18ba09495a82 | kzabashta/advent-of-code-17 | /day6/main_part2.py | 748 | 3.546875 | 4 | #!/usr/bin/env python
f = open('/Users/kosta/dev/advent-of-code-17/day6/input.txt')
banks = list(map(int, f.readline().split()))
i = 0
loops = 1
patterns = {}
circuit_breaker = False
while(True):
largest_index = 0
largest = banks[0]
# find largest index
for idx, bank in enumerate(banks):
if b... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.