blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
293e894a12b3f1064a46443f84cbfe4d0b70db6e | tuhiniris/Python-ShortCodes-Applications | /basic program/count set bits in a number.py | 724 | 4.21875 | 4 | """
The program finds the number of ones in the binary representation of a number.
Problem Solution
1. Create a function count_set_bits that takes a number n as argument.
2. The function works by performing bitwise AND of n with n – 1 and storing the result in n until n becomes 0.
3. Performing bitwise AND with n ... | true |
6d7a32d214efdcef903bd37f2030ea91df771a05 | tuhiniris/Python-ShortCodes-Applications | /number programs/check if a number is an Armstrong number.py | 414 | 4.375 | 4 | #Python Program to check if a number is an Armstrong number..
n = int(input("Enter the number: "))
a = list(map(int,str(n)))
print(f"the value of a in the program {a}")
b = list(map(lambda x:x**3,a))
print(f"the value of b in the program {b} and sum of elements in b is: {sum(b)}")
if sum(b)==n:
print(f"The numb... | true |
5f4083e687b65899f292802a57f3eb9b1b64ca5a | tuhiniris/Python-ShortCodes-Applications | /basic program/program takes an upper range and lower range and finds those numbers within the range which are divisible by 7 and multiple of 5.py | 295 | 4.125 | 4 | #program takes an upper range and lower range and finds those numbers within the range which are divisible by 7 and multiple of 5
lower = int(input("Enter the lower range: "))
upper = int(input("Enter the upper range: "))
for i in range(lower,upper+1):
if i%7 == 0 and i%5==0:
print(i)
| true |
7599d879058a9fca9866b3f68d93bcf2bda0001c | tuhiniris/Python-ShortCodes-Applications | /number programs/Swapping of two numbers without temperay variable.py | 1,492 | 4.15625 | 4 | ##Problem Description
##The program takes both the values from the user and swaps them
print("-------------------------------Method 1-----------------------")
a=int(input("Enter the First Number: "))
b=int(input("Enter the Second Number: "))
print("Before swapping First Number is {0} and Second Number is {1}" .f... | true |
ad835b40d50ac5db87b17903ac17f79c3fc820ef | tuhiniris/Python-ShortCodes-Applications | /matrix/find the transpose of a given matrix.py | 1,212 | 4.6875 | 5 | print('''
Note!
Transpose of a matrix can be found by interchanging rows with the column that is,
rows of the original matrix will become columns of the new matrix.
Similarly, columns in the original matrix will become rows in the new matrix.
If the dimension of the original matrix is 2 × 3 then,
the dimensio... | true |
ae96cee9c409b9af3ee4f2cca771093eb5fd32cd | tuhiniris/Python-ShortCodes-Applications | /list/Generate Random Numbers from 1 to 20 and Append Them to the List.py | 564 | 4.53125 | 5 | """
Problem Description
The program takes in the number of elements and generates random numbers from 1 to 20 and appends them to the list.
Problem Solution
1. Import the random module into the program.
2. Take the number of elements from the user.
3. Use a for loop, random.randint() is used to generate random ... | true |
4730566ea55fb752722cfb9257308de6de3ccc9c | tuhiniris/Python-ShortCodes-Applications | /recursion/Find if a Number is Prime or Not Prime Using Recursion.py | 539 | 4.25 | 4 | '''
Problem Description
-------------------
The program takes a number
and finds if the number is
prime or not using recursion.
'''
print(__doc__,end="")
print('-'*25)
def check(n, div = None):
if div is None:
div = n - 1
while div >= 2:
if n % div == 0:
print(f"Numbe... | true |
ef045cb0440d1fe1466a7fda39915e68db973872 | mwnickerson/python-crash-course | /chapter_9/cars_vers4.py | 930 | 4.1875 | 4 | # Cars version 4
# Chapter 9
# modifying an attributes vales through a method
class Car:
"""a simple attempt to simulate a car"""
def __init__(self, make, model, year):
"""Initialize attributes to describe a car"""
self.make = make
self.model = model
self.year = year
se... | true |
7e79127380cc86a94a1c4c5e836b8e00158481dc | mwnickerson/python-crash-course | /chapter_7/pizza_toppings.py | 321 | 4.28125 | 4 | # pizza toppings
# chapter 7 exercise 4
# a conditional loop that prompts user to enter toppings
prompt ="\nWhat topping would you like on your pizza?"
message = ""
while message != 'quit':
message = input(prompt)
topping = message
if message != 'quit':
print(f"I will add {topping} to your pizza!"... | true |
8b5ff94d3edf0eca7b35b1c67ea764816fe236aa | mwnickerson/python-crash-course | /chapter_6/cities.py | 623 | 4.125 | 4 | # Cities
# dictionaries inside of dictionaries
cities = {
'miami': {
'state': 'florida',
'sports team': 'hurricanes',
'attraction' : 'south beach'
},
'philadelphia': {
'state': 'pennsylvania',
'sports team': 'eagles',
'attraction': 'liberty bell'
},
'new york city': {
'state': 'new york',
'sports team': '... | false |
1520778db31a0b825694362dea70bd80327640d9 | mwnickerson/python-crash-course | /chapter_6/rivers.py | 605 | 4.5 | 4 | # a dictionary containing rivers and their country
# prints a sentence about each one
# prints river name and river country from a loop
rivers_0 = {
'nile' : 'egypt',
'amazon' : 'brazil',
'mississippi' : 'united states',
'yangtze' : 'china',
'rhine' : 'germany'
}
for river, country in rivers_0.ite... | false |
22bdf928b3a3d79e5dccd1361536f8fb7f0136f1 | mwnickerson/python-crash-course | /chapter_5/voting_vers2.py | 218 | 4.25 | 4 | # if and else statement
age = 17
if age >= 18:
print("You are able to vote!")
print("Have you registered to vote?")
else:
print("Sorry you are too young to vote.")
print("Please register to vote as you turn 18!")
| true |
7393500c1f9e8b7d3e3ceafce7f4e923d9111ae1 | hangnguyen81/HY-data-analysis-with-python | /part02-e13_diamond/diamond.py | 703 | 4.3125 | 4 | #!/usr/bin/env python3
'''
Create a function diamond that returns a two dimensional integer array where the 1s form a diamond shape.
Rest of the numbers are 0. The function should get a parameter that tells the length of a side of the diamond.
Do this using the eye and concatenate functions of NumPy and array slicing... | true |
14f3fd6898259a53461de709e7dc409a28ba829f | hangnguyen81/HY-data-analysis-with-python | /part01-e07_areas_of_shapes/areas_of_shapes.py | 902 | 4.15625 | 4 | #!/usr/bin/env python3
import math
def main():
while 1:
chosen = input('Choose a shape (triangle, rectangle, circle):')
chosen = chosen.lower()
if chosen == '':
break
elif chosen == 'triangle':
b=int(input('Give base of the triangle:'))
h=int(in... | true |
554a21528be4e8dc0ecdd9635196766071c0e4a0 | Julian-Arturo/FundamentosTaller-JH | /EjercicioN9.py | 1,323 | 4.59375 | 5 | """Mostrar en pantalla el promedio
de un alumno que ha cursado 5 materias
(Español, Matemáticas, Economía, Programación, Ingles)"""
#Programa que calcula el promedio de un estudiantes que cursa 5 materias
print ("Programa que calcula el promedio de un estudiantes que cursa 5 materias")
matematicas = 45
español = ... | false |
f86510558d0e668d9fc15fd0a3ff277ac93ec656 | keerthisreedeep/LuminarPythonNOV | /Functionsandmodules/function pgm one.py | 1,125 | 4.46875 | 4 | #function
#functions are used to perform a specific task
print() # print msg int the console
input() # to read value through console
int() # type cast to int
# user defined function
# syntax
# def functionname(arg1,arg2,arg3,.................argn):
# function defnition
#-----------------------------------------... | true |
cb1e9921d2f54d3bc3e3cb8bf67ca3e2af019197 | mgeorgic/Python-Challenge | /PyBank/main.py | 2,471 | 4.25 | 4 | # Import os module to create file paths across operating systems
# Import csv module for reading CSV files
import csv
import os
# Set a path to collect the CSV data from the Resources folder
PyBankcsv = os.path.join('Resources', 'budget_data.csv')
# Open the CSV in reader mode using the path above PyBankiv
with open ... | true |
dc56e7a5a4fa8422088b3e0cba4b78d2a86a1be3 | roctbb/GoTo-Summer-17 | /day 1/6_words.py | 425 | 4.15625 | 4 | word = input("введи слово:")
words = []
words.append(word)
while True:
last_char = word[-1]
new_word = input("тебе на {0}:".format(last_char.upper())).lower()
while not new_word.startswith(last_char) or new_word in words:
print("Неверно!")
new_word = input("тебе на {0}:".format(last_char.upp... | false |
672c5c943f6b90605cf98d7ac4672316df20773a | vittal666/Python-Assignments | /Third Assignment/Question-9.py | 399 | 4.28125 | 4 | word = input("Enter a string : ")
lowerCaseCount = 0
upperCaseCount = 0
for char in word:
print(char)
if char.islower() :
lowerCaseCount = lowerCaseCount+1
if char.isupper() :
upperCaseCount = upperCaseCount+1
print("Number of Uppercase characters in the string is :", lowerCaseCou... | true |
d614fd1df5ad36a1237a29c998e72af51dec2c99 | ahmedbodi/ProgrammingHelp | /minmax.py | 322 | 4.125 | 4 | def minmax(numbers):
lowest = None
highest = None
for number in numbers:
if number < lowest or lowest is None:
lowest = number
if number > highest or highest is None:
highest = number
return lowest, highest
min, max = minmax([1,2,3,4,5,6,7,8,9,10])
print(min, max... | true |
7e22899c704700d2d302fed476d6237c6a0ad4c8 | JeonWookTae/fluent_python | /chapter2/list_in_list.py | 523 | 4.125 | 4 | board = [['_']*3 for _ in range(3)]
print(board)
board[2][1] = 'X'
print(board)
# [['_', '_', '_'], ['_', '_', '_'], ['_', 'X', '_']]
# 참조를 가진 3개의 리스트가 생성된다.
board = [['_']*3]*3
print(board)
board[2][1] = 'X'
print(board)
# [['_', 'X', '_'], ['_', 'X', '_'], ['_', 'X', '_']]
l = [1,2,3]
print(id(l))
l *= 2
print(id... | false |
fa050769df11502c362c3f7000dae14a0373a5c9 | jbenejam7/Ith-order-statistic | /insertionsort.py | 713 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 29 18:02:06 2021
@author: djwre
"""
import random
#Function for InsertionSort
def InsertionSort(A, n):
#traverse through 1 to len(arr)
for i in range(1, n):
key = A[i]
#move elements of arr [0..i-1], that are
#great... | true |
9a6829d0e2e6cd55e7b969674845a733a14d31d2 | rabi-siddique/LeetCode | /Lists/MergeKSortedLists.py | 1,581 | 4.4375 | 4 | '''
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
Example 1:
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Explanation: The linked-lists are:
[
1->4->5,
1->3->4,
2->6
]
m... | true |
55d2c65bb61b82e52e00c2f2f768399f17e78367 | evanmascitti/ecol-597-programming-for-ecologists | /Python/Homework_Day4_Mascitti_problem_2.py | 2,766 | 4.40625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 1 21:16:35 2021
@author: evanm
"""
# assign raw data to variables
observed_group_1_data = [1, 4, 5, 3, 1, 5, 3, 7, 2, 2]
observed_group_2_data = [6, 7, 9, 3, 5, 7, 8, 10, 12]
combined_data = observed_group_1_data + observed_group_2_data
# define a func... | true |
b33973eb0714d992fdccd08ed66588930020244e | ckubelle/SSW567-HW1 | /hw01triangle.py | 2,062 | 4.125 | 4 |
import unittest
import math
def classify_triangle(a,b,c):
if a == b and b == c:
return "Equilateral"
if a == b or b == c or a == c:
if int(a*a + b*b) == int(c*c):
return "Right Isosceles"
else:
return "Isosceles"
if int(a*a + b*b) == i... | false |
373ecc01e393f54d7d67e3fcba648bc9bdae323f | Teresa-Rosemary/Text-Pre-Processing-in-Python | /individual_python_files/word_tokenize.py | 880 | 4.15625 | 4 | # coding: utf-8
import nltk
from nltk import word_tokenize
def word_tokenize(text):
"""
take string input and return list of words.
use nltk.word_tokenize() to split the words.
"""
word_list=[]
for sentences in nltk.sent_tokenize(text):
for words in nltk.word_tokenize(sentences):
... | true |
60154b97d18346acc13abb79f1026e4cf07f80e0 | scott-currie/data_structures_and_algorithms | /data_structures/binary_tree/binary_tree.py | 1,400 | 4.125 | 4 | from queue import Queue
class Node(object):
""""""
def __init__(self, val):
""""""
self.val = val
self.left = None
self.right = None
def __repr__(self):
""""""
return f'<Node object: val={ self.val }>'
def __str__(self):
""""""
return ... | true |
9964fcd07621271656f2ad95b8befd93f6546a54 | scott-currie/data_structures_and_algorithms | /data_structures/stack/stack.py | 1,756 | 4.15625 | 4 | from .node import Node
class Stack(object):
"""Class to implement stack functionality. It serves as a wrapper for
Node objects and implements push, pop, and peek functionality. It also
overrides __len__ to return a _size attribute that should be
updated by any method that adds or removes nodes from th... | true |
134ad277c30c6f24878f0e7d38c238f147196a64 | scott-currie/data_structures_and_algorithms | /challenges/array_binary_search/array_binary_search.py | 788 | 4.3125 | 4 | def binary_search(search_list, search_key):
"""Find the index of a value of a key in a sorted list using
a binary search algorithm. Returns the index of the value if
found. Otherwise, returns -1.
"""
left_idx, right_idx = 0, len(search_list) - 1
# while True:
while left_idx <= right_idx:
... | true |
16f21ae65b3d5e3aba3f44decb5a1a4c556c95a5 | scott-currie/data_structures_and_algorithms | /challenges/multi-bracket-validation/multi_bracket_validation.py | 900 | 4.25 | 4 | from stack import Stack
def multi_bracket_validation(input_str):
"""Parse a string to determine if the grouping sequences within it are
balanced.
param: input_str (str) string to parse
return: (boolean) True if input_str is balanced, else False
"""
if type(input_str) is not str:
raise... | true |
d46fc6f5940512ae2764ba93f4ad59d920ea16c4 | rentheroot/Learning-Pygame | /Following-Car-Game-Tutorial/Adding-Boundries.py | 2,062 | 4.25 | 4 | #learning to use pygame
#following this tutorial: https://pythonprogramming.net/displaying-images-pygame/?completed=/pygame-python-3-part-1-intro/
#imports
import pygame
#start pygame
pygame.init()
#store width and height vars
display_width = 800
display_height = 600
#init display
gameDisplay = pygame.display.set_m... | true |
49fe160812ab26303e82a2bead21905940f5e626 | lpizarro2391/HEAD-FIRST-PYTHON | /vowels3.py | 331 | 4.15625 | 4 | vowels=['a','e','i','o','u']
word=input("Provide a word to searh for vowels: ")
found=[]
for letter in word:
if letter in vowels:
if letter not in found:
found.append(letter)
for vowel in found:
print(vowel)
found={}
for k in sorted (found):
print(k,'was found', found[k],'... | false |
a0e4c3feb2b27548e37c583aa5c091110329d73a | logan-ankenbrandt/LeetCode | /RemoveVowels.py | 1,043 | 4.21875 | 4 | def removeVowels(s: str) -> str:
"""
1. Goal
- Remove all vowels from a string
2. Example
- Example #1
a. Input
i. s = "leetcodeisacommunityforcoders"
b. Output
i. "ltcdscmmntyfcfgrs"
- E... | true |
e696cb31e3dd97c552b6b3206798e74a29027b0d | logan-ankenbrandt/LeetCode | /MajorityElement.py | 1,072 | 4.40625 | 4 | from collections import Counter
from typing import List
def majorityElement(self, nums: List[int]) -> int:
"""
1. Goal
a. Return the most frequent value in a list
2. Examples
a. Example #1
- Input
i. nums = [3, 2, 3]
- Output
i. 3
... | true |
150c6c8f6e603b1ab89367e04150829b11c31df3 | logan-ankenbrandt/LeetCode | /MostCommonWord.py | 1,404 | 4.125 | 4 | from typing import List
from collections import Counter
import re
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str:
"""
1. Goal
- Return the most common word in a string that is not banned
2. Examples
- Example #1
a. Input
... | true |
441be31aa36e6c446bc891e5cb84e0ee9abdb924 | logan-ankenbrandt/LeetCode | /CountSubstrings.py | 1,979 | 4.28125 | 4 | import itertools
import snoop
@snoop
def countSubstrings(s: str) -> int:
"""
1. Goal
- Count the number of substrings that are palindromes.
2. Examples
- Example #1
a. Input
i. "abc"
b. Output
i. 3
c. Explanation
... | true |
a3ae007c55ee2cfe220cd9094b4eaa38822ded38 | CountTheSevens/dailyProgrammerChallenges | /challenge001_easy.py | 803 | 4.125 | 4 | #https://www.reddit.com/r/dailyprogrammer/comments/pih8x/easy_challenge_1/
# #create a program that will ask the users name, age, and reddit username. have it tell them the information back,
#in the format: your name is (blank), you are (blank) years old, and your username is (blank)
#for extra credit, have the program... | true |
199cc666d97a3fdc6e1afc98ec06c33f005ae051 | iSkylake/Algorithms | /Tree/ValidBST.py | 701 | 4.25 | 4 | # Create a function that return True if the Binary Tree is a BST or False if it isn't a BST
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def valid_BST(root):
inorder = []
def traverse(node):
nonlocal inorder
if not node:
return
traverse(node.left)
inorder.... | true |
7c6895415c7f493062c06626e567fa32c3e66928 | iSkylake/Algorithms | /Array/Merge2Array.py | 735 | 4.15625 | 4 | # Given two sorted arrays, merge them into one sorted array
# Example:
# [1, 2, 5, 7], [3, 4, 9] => [1, 2, 3, 4, 5, 7, 9]
# Suggestion:
# Time: O(n+m)
# Space: O(n+m)
from nose.tools import assert_equal
def merge_2_array(arr1, arr2):
result = []
i, j = 0, 0
while i < len(arr1) and j < len(arr2):
if arr1[i] <= ... | false |
92803502bd1d37d5c73015816ba141e760938491 | iSkylake/Algorithms | /Linked List/LinkedListReverse.py | 842 | 4.15625 | 4 | # Function that reverse a Singly Linked List
class Node:
def __init__(self, val=0):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def append(self, val):
new_node = Node(val)
if self.length == 0:
self.head = new_node
else:... | true |
0824e7d93385a87358503bc289e984dfeae38f8c | hShivaram/pythonPractise | /ProblemStatements/EvenorOdd.py | 208 | 4.4375 | 4 | # Description
# Given an integer, print whether it is Even or Odd.
# Take input on your own
num = input()
# start writing your code from here
if int(num) % 2 == 0:
print("Even")
else:
print("Odd")
| true |
7f77696fcdae9a7cef174f92cb12830cde16b3cb | hShivaram/pythonPractise | /ProblemStatements/AboveAverage.py | 1,090 | 4.34375 | 4 | # Description: Finding the average of the data and comparing it with other values is often encountered while analysing
# the data. Here you will do the same thing. The data will be provided to you in a list. You will also be given a
# number check. You will return whether the number check is above average or no.
#
# -... | true |
5b54d69790c6d524c1b253b8bec1c32ad83c4bf8 | LoktevM/Skillbox-Python-Homework | /lesson_011/01_shapes.py | 1,505 | 4.25 | 4 | # -*- coding: utf-8 -*-
# На основе вашего кода из решения lesson_004/01_shapes.py сделать функцию-фабрику,
# которая возвращает функции рисования треугольника, четырехугольника, пятиугольника и т.д.
#
# Функция рисования должна принимать параметры
# - точка начала рисования
# - угол наклона
# - длина стороны
... | false |
63a055bb9ee454b6c6ad68defb6b540b6cb74323 | Hosen-Rabby/Guess-Game- | /randomgame.py | 526 | 4.125 | 4 | from random import randint
# generate a number from 1~10
answer = randint(1, 10)
while True:
try:
# input from user
guess = int(input('Guess a number 1~10: '))
# check that input is a number
if 0 < guess < 11:
# check if input is a right guess
if guess == answ... | true |
233b8e8cc6295adad5919285230971a293dfde80 | abhaydixit/Trial-Rep | /lab3.py | 430 | 4.1875 | 4 | import turtle
def drawSnowFlakes(depth, length):
if depth == 0:
return
for i in range(6):
turtle.forward(length)
drawSnowFlakes(depth - 1, length/3)
turtle.back(length)
turtle.right(60)
def main():
depth = int(input('Enter depth: '))
drawSnowFlakes(depth, 100)... | true |
51558f22e5262038813d7f4ce3e5d2ad2836e6d9 | Creativeguru97/Python | /Syntax/ConditionalStatementAndLoop.py | 1,372 | 4.1875 | 4 | #Condition and statement
a = 300
b = 400
c = 150
# if b > a:
# print("b is greater than a")
# elif a == b:
# print("a and b are equal")
# else:
# print("a is greater than b")
#If only one of statement to excute, we can put togather
# if a == b: print("YEAHHHHHHHHH !!!!!!!!!!!")
# print("b is greater than... | false |
d988912a14c4fe3d6bb41458d10898d6cddc991a | fairypeng/a_python_note | /leetcode/977有序数组的平方.py | 825 | 4.1875 | 4 | #coding:utf-8
"""
给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序。
示例 1:
输入:[-4,-1,0,3,10]
输出:[0,1,9,16,100]
示例 2:
输入:[-7,-3,2,3,11]
输出:[4,9,9,49,121]
提示:
1 <= A.length <= 10000
-10000 <= A[i] <= 10000
A 已按非递减顺序排序。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/squares-of-a-sorted-array
著作权归领扣网络所有。商业转载... | false |
663ac97205d487837d27cd973cb1a91bdf9b8702 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2b/Questão 7.py | 1,890 | 4.25 | 4 | #7. As Organizações Tabajara resolveram dar um aumento de salário aos seus colaboradores e lhe
#contrataram para desenvolver o programa que calculará os reajustes. Escreva um algoritmo que leia o
#salário de um colaborador e o reajuste segundo o seguinte critério, baseado no salário atual:
#o salários até R$ 280,00 ... | false |
9921976bf20825da1a5ce71bf4ba52d01ee5f106 | Antoniel-silva/ifpi-ads-algoritmos2020 | /App celular.py | 2,066 | 4.15625 | 4 | def main():
arquivo = []
menu = tela_inicial()
opcao = int(input(menu))
while opcao != 0:
if opcao == 1:
listacel = cadastrar()
arquivo.append(listacel)
elif opcao == 2:
lista = listar(arquivo)
... | false |
4bb55dfeb2640ca2ba99d32ff68d1c1440126898 | Antoniel-silva/ifpi-ads-algoritmos2020 | /Fabio 2b/Questão 13.py | 1,567 | 4.21875 | 4 | #13. Faça 5 perguntas para uma pessoa sobre um crime. As perguntas são:
#a) "Telefonou para a vítima ?"
#b) "Esteve no local do crime ?"
#c) "Mora perto da vítima ?"
#d) "Devia para a vítima ?"
#e) "Já trabalhou com a vítima ?"
#O algoritmo deve no final emitir uma classificação sobre a participação da pessoa no ... | false |
373d5194589ea6da392963fa046cb8478a9d52c4 | yegeli/Practice | /第16章/threading_exercise02.py | 483 | 4.15625 | 4 | """
使用Thread子类创建进程
"""
import threading
import time
class SubThread(threading.Thread):
def run(self):
for i in range(3):
time.sleep(1)
msg = "子线程" + self.name + "执行,i=" + str(i)
print(msg)
if __name__ == "__main__":
print("------主进程开始-------")
t1 = SubThre... | false |
df273e0b1a4ec97f7884e64e0fe1979623236fb2 | bdjilka/algorithms_on_graphs | /week2/acyclicity.py | 2,108 | 4.125 | 4 | # Uses python3
import sys
class Graph:
"""
Class representing directed graph defined with the help of adjacency list.
"""
def __init__(self, adj, n):
"""
Initialization.
:param adj: list of adjacency
:param n: number of vertices
"""
self.adj = adj
... | true |
4b3922cdedf4f4c7af87235b94af0f763977b191 | nguyenl1/evening_class | /python/labs/lab23final.py | 2,971 | 4.25 | 4 | import csv
#version 1
# phonebook = []
# with open('lab23.csv') as file:
# read = csv.DictReader(file, delimiter=',')
# for row in read:
# phonebook.append(row)
# print(phonebook)
#version2
"""Create a record: ask the user for each attribute, add a new contact to your contact list with the attr... | false |
3bd0c70f91a87d98797984bb0b17502eac466972 | nguyenl1/evening_class | /python/labs/lab18.py | 2,044 | 4.40625 | 4 | """
peaks - Returns the indices of peaks. A peak has a lower number on both the left and the right.
valleys - Returns the indices of 'valleys'. A valley is a number with a higher number on both the left and the right.
peaks_and_valleys - uses the above two functions to compile a single list of the peaks and valleys i... | true |
39c5729b31befc2a988a0b3ac2672454ae99ea9a | krsatyam20/PythonRishabh | /cunstructor.py | 1,644 | 4.625 | 5 | '''
Constructors can be of two types.
Parameterized/arguments Constructor
Non-parameterized/no any arguments Constructor
__init__
Constructors:self calling function
when we will call class function auto call
'''
#create class and define function
class aClass:
# Constructor with arguments
def... | true |
f2744631653064a83857180583c831b187a8f53c | TiwariSimona/Hacktoberfest-2021 | /ajaydhoble/euler_1.py | 209 | 4.125 | 4 | # List for storing multiplies
multiplies = []
for i in range(10):
if i % 3 == 0 or i % 5 == 0:
multiplies.append(i)
print("The sum of all the multiples of 3 or 5 below 1000 is", sum(multiplies))
| true |
16ad6fbbb5ab3f9a0e638a1d8fd7c4469d349c11 | TiwariSimona/Hacktoberfest-2021 | /parisheelan/bmi.py | 957 | 4.15625 | 4 | while True:
print("1. Metric")
print("2. Imperial")
print("3. Exit")
x=int(input("Enter Choice (1/2/3): "))
if x==1:
h=float(input("Enter height(m) : "))
w=float(input("Enter weight(kg) : "))
bmi=w/h**2
print("BMI= ",bmi)
if bmi<=18.5:
print("Under... | false |
0211584a0d5087701ee07b79328d4eb6c101e962 | pintugorai/python_programming | /Basic/type_conversion.py | 438 | 4.1875 | 4 | '''
Type Conversion:
int(x [,base])
Converts x to an integer. base specifies the base if x is a string.
str(x)
Converts object x to a string representation.
eval(str)
Evaluates a string and returns an object.
tuple(s)
Converts s to a tuple.
list(s)
Converts s to a list.
set(s)
Converts s to a set.
dict(d)
Creates... | true |
3597f00172708154780a6e83227a7930e034d166 | csu100/LeetCode | /python/leetcoding/LeetCode_225.py | 1,792 | 4.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/1/31 10:37
# @Author : Zheng guoliang
# @Version : 1.0
# @File : {NAME}.py
# @Software: PyCharm
"""
1.需求功能:
https://leetcode-cn.com/problems/implement-stack-using-queues/
使用队列实现栈的下列操作:
push(x) -- 元素 x 入栈
pop() -- 移除栈顶元素
top() -- 获取栈顶元素
... | true |
0768a12697cd31a72c3d61ecfa4eda9a1aa0751e | csu100/LeetCode | /python/leetcoding/LeetCode_232.py | 1,528 | 4.46875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/1/31 17:28
# @Author : Zheng guoliang
# @Version : 1.0
# @File : {NAME}.py
# @Software: PyCharm
"""
1.需求功能:
https://leetcode-cn.com/problems/implement-queue-using-stacks/submissions/
使用栈实现队列的下列操作:
push(x) -- 将一个元素放入队列的尾部。
pop() -- 从队列首部移除元素。
... | false |
d57b48fe6ebac8c1770886f836ef17f3cadf16c7 | alma-frankenstein/Grad-school-assignments | /montyHall.py | 1,697 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#to illustrate that switching, counterintuitively, increases the odds of winning.
#contestant CHOICES are automated to allow for a large number of test runs, but could be
#changed to get user input
import random
DOORS = ['A', 'B', 'C']
CHOICES = ["stay", "switch"]
de... | true |
8b8644a5fbc3a44baff3a5ad1156c5a644b60f56 | drod1392/IntroProgramming | /Lesson1/exercise1_Strings.py | 1,026 | 4.53125 | 5 | ## exercise1_Strings.py - Using Strings
#
# In this exercise we will be working with strings
# 1) We will be reading input from the console (similar to example2_ReadConsole.py)
# 2) We will concatenate our input strings
# 3) We will convert them to upper and lowercase strings
# 4) Print just the last name from the "nam... | true |
df9cea82395dfc4c540ffe7623a0120d2483ea9e | imyogeshgaur/important_concepts | /Python/Exercise/ex4.py | 377 | 4.125 | 4 | def divideNumber(a,b):
try:
a=int(a)
b=int(b)
if a > b:
print(a/b)
else:
print(b/a)
except ZeroDivisionError:
print("Infinite")
except ValueError:
print("Please Enter an Integer to continue !!!")
num1 = input('Enter first number')
num2... | true |
2d95e7c4a3ff636c2ec5ff400e43d273bc479f48 | akshitha111/CSPP-1-assignments | /module 22/assignment5/frequency_graph.py | 829 | 4.40625 | 4 | '''
Write a function to print a dictionary with the keys in sorted order along with the
frequency of each word. Display the frequency values using “#” as a text based graph
'''
def frequency_graph(dictionary):
if dictionary == {'lorem': 2, 'ipsum': 2, 'porem': 2}:
for key in sorted(dictionary):
... | true |
a5c6578d3af315b00a5f2c2278d8f3ab1ef969a0 | edgeowner/Python-Basic | /codes/3_2_simple_calculator.py | 679 | 4.34375 | 4 | error = False
try:
num1 = float(input("the first number: "))
except:
print("Please input a number")
error = True
try:
num2 = float(input("the second number: "))
except:
print("Please input a number")
error = True
op = input("the operator(+ - * / **):")
if error:
print("Something Wrong")
e... | false |
e51964055f7eea8dc2c8a3d38601dd48aacf7bc1 | edgeowner/Python-Basic | /codes/2_exercise_invest.py | 211 | 4.1875 | 4 | money = float(input("How much money"))
month = float(input("How many months"))
rate = float(input("How much rate"))
rate = rate / 100
total = money * (1 + rate) ** month
interest = total - money
print(interest)
| false |
f0995f652df181115268c78bbb649a6560108f47 | ciciswann/interview-cake | /big_o.py | 658 | 4.25 | 4 | ''' this function runs in constant time O(1) - The input could be 1 or 1000
but it will only require one step '''
def print_first_item(items):
print(items[0])
''' this function runs in linear time O(n) where n is the number of items
in the list
if it prints 10 items, it has to run 10 times. If it prints 1,000 it... | true |
29a21b7d3b694268ebc6362f1dc4bb044c2b3883 | luispaulojr/cursoPython | /semana_01/aula01/parte02_condicionais.py | 309 | 4.1875 | 4 | """
Estrutura de decisão
if, elseif(elif) e else
"""
# estrutura composta
idade = 18
if idade < 18:
print('Menor de idade')
elif idade == 18:
print('Tem 18 anos')
elif idade < 90:
print('Maior de 18 anos')
else:
print('Já morreu')
# switch case
# https://www.python.org/dev/peps/pep-0634/
| false |
a39d746b7b7b615e54c0266aba519956a96c492c | luispaulojr/cursoPython | /semana_02/aula/tupla.py | 871 | 4.40625 | 4 | """
Tuplas são imutáveis
arrays - listas são mutáveis
[] utilizado para declaração de lista
() utilizado para declaração de tupla
"""
"""
# declaração de uma tupla utilizando parenteses
"""
tupla1 = (1, 2, 3, 4, 5, 6)
print(tupla1)
"""
# declaração de uma tupla não utilizando parenteses
"""
tupla2 = 1... | false |
d0249ae72e0a0590cffda71a48c5df0993d1ee18 | zongxinwu92/leetcode | /CountTheRepetitions.py | 788 | 4.125 | 4 | '''
Created on 1.12.2017
@author: Jesse
''''''
Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] ="abcabcabc".
On the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For example, “abc... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.