blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
079df767f942e053cc7c3da2ac52b214e2f76dd9 | chinatsui/DimondDog | /algorithm/exercise/dfs/flatten_binary_tree_to_linked_list.py | 1,324 | 4.21875 | 4 | """
LeetCode-114
Given a binary tree, flatten it to a linked list in-place.
For example, given the following tree:
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6
"""
from algorithm.core.binary_tree import Bin... | true |
8cc0098cb8f8632608a151d3b7767d43fd5bd03b | pacheco-andres/nuevos-archivos- | /venta_libros.py | 912 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
books = {"matematicas": 100, "espaniol": 90, "biologia": 70, "historia": 80, "fisica":110}
def show_books():
counter = 1
print("VENTA DE LIBROS")
for book in books.keys():
print ('%s.- %s') %(counter, book)
counter += 1
def get_input():
tr... | false |
7fba688e38fd71770a82e5fd1b679b3310b07eb0 | JeremyJMoss/NumberGuessingGame | /main.py | 837 | 4.125 | 4 | import random
print("Welcome to the Number Guessing Game!")
print("I'm thinking of a number between 1 and 100")
randomNum = random.randint(1, 101);
difficulty = input("Choose a difficulty. Type 'easy' or 'hard': ")
if difficulty == "easy":
attempts = 10
else:
attempts = 5
game_over = False
while game_over == False... | true |
c907b392e1ee740c0f8d88935014170850865099 | award96/teach_python | /B-variables.py | 1,489 | 4.53125 | 5 | """
Variables are necessary to keep track of data, objects, whatever. Each variable
in Python has a name and a pointer. The name is how you call the variable ('a' in the lines below)
and the pointer 'points' to the object in memory. The pointer can change as you reassign the variable (as I do below)
This is import... | true |
be8450d8e7bd73004d0e181703dc1175e1309139 | nebkor/lpthw | /ex32.py | 870 | 4.59375 | 5 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'appricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
# this first kind of for-loop goes through a list
for number in the_count:
print "This is the count %d" % number
# same as above
for fruit in fruits:
print "A fruit of type: ... | true |
9ceec7eae46ff248dbcdcfa1146738bea6b517cc | nebkor/lpthw | /ex20.py | 2,230 | 4.25 | 4 | # import sys.argv into the global namespace as argv
from sys import argv
# assign script to the 0th entry in the argv array and input_file
# to the 1th entry in the argv array
script, input_file = argv
# Define the function "print_all()" which takes an argument as f
def print_all(f):
print f.read() # print... | true |
ad25f8423417bd2f9de0ea80ae9c97bc53635969 | nebkor/lpthw | /joe/ex15.py | 1,594 | 4.625 | 5 | # import sys.argv into the global namespace as argv
from sys import argv
# assign to the 'script' variable the value of argv[0],
# assign to the 'filename' variable the value of argv[1]
script, filename = argv
# assign to the 'txt' variable the value returned by the
# function "open()", which was called with the vari... | true |
86555752f784eec78689d6fd691753ed4a9f8cb9 | yoavbargad/self.py-course-python | /Unit 4/unit 4 - 4.2.4.py | 219 | 4.21875 | 4 | # Python Course - unit 4
# 4.2.4
import calendar
day_list = list(calendar.day_name)
date = input('Enter a date (dd/mm/yyyy):\t')
day = calendar.weekday(int(date[6:]), int(date[3:5]), int(date[:2]))
print(day_list[day]) | false |
4272bcf4fdcdee3dfeada312f6e5325d6bc70760 | Dylan-Lebedin/Computer-Science-1 | /Homework/test_debug2.py | 2,868 | 4.1875 | 4 | """
This program includes a function to find and return
the length of a longest common consecutive substring
shared by two strings.
If the strings have nothing in common, the longest
common consecutive substring has length 0.
For example, if string1 = "established", and
string2 = "ballistic", the function re... | true |
9956f0ea9beb16499bd04955fef4a03c471577e9 | BassP97/CTCI | /Hard/surroundedRegions.py | 1,912 | 4.15625 | 4 | """
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions
surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
Example:
X X X X
X O O X
X X O X
X O X X
After running your function, the board should be:
X X X X
X X X X
X X X X
X O X X
"""
#searches ... | true |
87a7fea85665c6937299d627e8f48b742e35e359 | BassP97/CTCI | /Med/mergeTimes.py | 1,123 | 4.21875 | 4 | """
Write a function merge_ranges() that takes a list of multiple meeting
time ranges and returns a list of condensed ranges.
For example, given:
[(0, 1), (3, 5), (4, 8), (10, 12), (9, 10)]
your function would return:
[(0, 1), (3, 8), (9, 12)]
Do not assume the meetings are in order. The meeting times are c... | true |
d6181901165881a52d73d399e7939c1300118b1f | BassP97/CTCI | /Med/reverseLLInplace.py | 456 | 4.25 | 4 | """
Write a function for reversing a linked list. Do it in place.
Your function will have one input: the head of the list.
Your function should return the new head of the list.
Here's a sample linked list node class:
"""
def revLL(head):
if head.next is None:
return head
curr = head.next
prev =... | true |
838b2e05a36c9c8df569a7c01e631711e6dba849 | BassP97/CTCI | /Med/shortEncoding.py | 716 | 4.40625 | 4 | """
Given a list of words, we may encode it by writing a reference string S and a list of indexes A.
For example, if the list of words is ["time", "me", "bell"], we can write it as S = "time#bell#"
and indexes = [0, 2, 5].
Then for each index, we will recover the word by reading from the reference string from that i... | true |
f42be0825f831246d8fb0dae883522ca8281bbba | BassP97/CTCI | /2021 prep/zigZagOrder.py | 1,165 | 4.125 | 4 | """
Given a binary tree, return the zigzag level order traversal
of its nodes' values. (ie, from left to right, then right to
left for the next level and alternate between).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its zigzag level order traversal as:
[
... | true |
26c13d5967797a8dbd118c174099395213d62b03 | BassP97/CTCI | /Easy/diameterOfBinaryTree.py | 636 | 4.15625 | 4 | """
Given a binary tree, you need to compute the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two
nodes in a tree. This path may or may not pass through the root.
Note - too lazy to implement a real tree so logic will have to do
"""
class Solution(ob... | true |
721a58fcb536b1692f35c9337676f6855200c61e | BassP97/CTCI | /Med/validateBST.py | 1,034 | 4.15625 | 4 | """
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys greater than the node's key.
Both the left and righ... | true |
fa876691a18d78065d3af8a9aff74eb8a14ccede | anishLearnsToCode/python-training-1 | /solution-bank/loop/solution_8.py | 368 | 4.1875 | 4 | """
WAP that prompts the user to input a positive integer. It should then output a message
indicating whether the number is a prime number.
"""
number = int(input())
is_prime = True
for i in range(2, number):
if number % i == 0:
print('composite number')
is_prime = False
break
if is_prime... | true |
909a76f6f26af2922d5de1e25247bf11ed1e805f | anishLearnsToCode/python-training-1 | /solution-bank/loop/solution_6.py | 210 | 4.21875 | 4 | """
WAP that prompts the user to input an integer and then outputs the number with the digits reversed.
For example, if the input is 12345, the output should be 54321.
"""
number = input()
print(number[::-1])
| true |
a298b6e9d0490deeef0a2688b072d88f686a2ddc | anishLearnsToCode/python-training-1 | /day_1/print_funtion.py | 273 | 4.25 | 4 | """
Time Complexity: O(1)
Space Complexity: O(1)
"""
print('hello world', end=' ** ')
print('this is amazing!!!')
print('i am on top of the world')
print('\ni am on a new line\n\n', end='***')
print('\tsomething\ni am once again on a new line\t\t', end='this is the end')
| false |
8d2b67127264b57599932c5c94d8cd81b3df0e3c | apisourse/netology_python | /1-06/1-6__init__.py | 943 | 4.1875 | 4 | class Car:
# pass #просто заглушка, если класс пустой, если не пустой, то писать не нужно
# Создаем атрибуты класса
color = 'black'
engine_volume = 1500
year = 2018
fuel = 0 #l
position = 0
speed = 0 #km/h
status = 'stopped'
coords = [0, 0, 0]
def __init__(self, fuel, position):
self.coords = [... | false |
5a5773da9a58a0f0688fbd7730ee89ff1907a226 | virensachdev786/my_python_codes | /pyDS.py | 992 | 4.25 | 4 | def main():
#LIST
# print("Enter the size of list")
# n = int(input())
# a = list()
#
# for i in range(n):
# print("enter elements of list: ")
# c = int(input())
# a.append(c)
#
# print("the entered list is: {0} ".format(a))
#Tuple
# print("Enter size of... | false |
400e46df1e58b1a6914e2e72e63ba6323e9e04f8 | josephwalker504/python-set | /cars.py | 1,470 | 4.125 | 4 | # Create an empty set named showroom.
showroom = set()
# Add four of your favorite car model names to the set.
showroom = {"model s", "camaro", "DB11", "B7"}
print(showroom)
# Print the length of your set.
print("length of set",len(showroom))
# Pick one of the items in your show room and add it to the set again.
... | true |
91edad8c1a7978d660c77fcc7606c71e96773fe8 | shereenElSayed/python-github-actions-demo | /src/main.py | 885 | 4.15625 | 4 | #!/usr/bin/python3
import click
from src import calculations as calc
@click.command()
@click.option('--name', prompt='Enter your name',
help='The person to greet.')
def welcome(name):
"""Simple program that greets NAME for a total of COUNT times."""
click.echo(f'Hello {name}')
@click.command()... | true |
cb14a75694c303c8ced888a2dbb06d95cf424a82 | niranjanvl/test | /py/misc/word_or_not.py | 611 | 4.40625 | 4 | #--------------------------
# for each of the given argument
# find out if it is a word or not
#
# Note : Anything not a number is a Word
#
# word_or_not.py 12 1 -1 abc 123b
# 12 : Not a Word
# 1 : Not a Word
# -1 : Not a Word
# abc : Word
# 123b : Word
#--------------------------
import sys
values = sys.argv[1:]
... | true |
737013cf2ef608e5a672dbcbb129137ade18f9e9 | niranjanvl/test | /py/misc/gen_odd_even.py | 2,505 | 4.34375 | 4 | '''
Generate odd/even numbers between the given numbers (inclusive).
The choice and the range is given as command line arguments.
e.g.,
gen_odd_even.py <odd/even> <int> <int>
odd/even : can be case insensitive
range can be ascending or descending
gen_odd_even.py odd 2 10
3, 5, 7, 9
gen_odd_even.py odd 10 ... | true |
82ef0d627b03c478a1988b33cc7f81cb04493380 | niranjanvl/test | /py/misc/power.py | 438 | 4.28125 | 4 | import sys
def pow(x,y):
#x to the power of y
result = 1
if y > 0:
#repetitive multiplication
i = 0
while i < y:
result *= x
i += 1
elif y < 0:
#repetitive division
i = y
while i < 0:
result /= x
i += 1
... | true |
41099a375c5cbe212a9d4dafe8d98f6fd3c341db | abhishekboy/MyPythonPractice | /src/main/python/04Expressions.py | 934 | 4.125 | 4 | a =12
b =3
print (a+b) # 15
print(a-b) # 9
print(a*b) # 36
print(a/b) # 4.0
print(a//b) #interger division,rounder down to minus infinity
print(a % b) #modulo : remainder after interger division
print(a**b) #a power b
print() #print empty line
# in below code a/b can't be used as it will ... | true |
b05d92cbbb972902b5fb5b6ca213408d6d8b77a9 | Mjayendr/My-Python-Learnings | /discon.py | 1,409 | 4.375 | 4 | # This program converts distance from feet to either inches, yards or meters.
# By: Jay Monpara
def main():
print
invalid = True
while invalid:
while True:
try: # using try --- except statements for numeric validation
distance = raw_input("Enter the distance in feet: ") # prompt user to... | true |
66ce742e5725c7d94a6e119ae5fbe050d6ec5d0e | Mjayendr/My-Python-Learnings | /Temperatur C to F.py | 644 | 4.375 | 4 | #A program to convert temperature from degree celcius to Degree farenheit.
# By Jay Monpara
def Main():
print
Celcius = input("What is the temperature in celcius?") # provoke user to input celcius temperature.
Fahrenheit = (9.0/5.0) * Celcius + 32 # process to convert celcius into fahrenheit
pri... | true |
fc62d6f18d7bd1e3ff07e8640c79e1216999b294 | markser/InClassGit3 | /wordCount.py | 643 | 4.28125 | 4 | # to run the program
# python3 wordCount.py
# then input string that we want to retrieve the number of words in the given string
def wordCount(userInputString):
return (len(userInputString.split()))
def retrieve_input():
userInputString = (input('Input a string to determine amount of words: '))
if len(us... | true |
19d5309eeeb5429350a3e3dae8368c265c4d3034 | zhangwhitemouse/pythonDataStructure | /datastructure/python-data-structure-linkedlist/reverselinkedlist.py | 2,242 | 4.4375 | 4 | """
反转链表
问题分析:反转链表就是将单链表的每个节点的指针域指向前一个节点,头节点特殊一点,它需要指向None
算法分析:第一反应就是暴力解法呀,就是将单链表的每个元素拿出来放入列表,然后再构建一遍链表(被自己蠢到了哈哈哈)。
然后想了想发现我用两个变量,一个存储当前节点,一个存放当前节点的前一个节点不就行了
"""
# class Solution:
# def reverseList(self, head):
# prev = None
# curr = head
# while curr != None:
# temp = cur... | false |
43e89a01a12c0e2d0ccf2731e8edefa283daff37 | mageoffat/Python_Lists_Strings | /Rotating_List.py | 1,291 | 4.4375 | 4 | # Write a function that rotates a list by k elements.
# For example [1,2,3,4,5,6] rotated by two becomes [3,4,5,6,1,2].
# Try solving this without creating a copy of the list.
# How many swap or move operations do you need?
num_list = [1,2,3,4,5,6,7,8,9] # my numbered list
val = 0 # value
def rotation(num_... | true |
13ecd656f3fe1fa576935a259ee42f8c180c22b2 | akimmi/cpe101 | /poly.py | 591 | 4.1875 | 4 | import math
# the purpose of this function is add the values inside the list
# list, list --> list
def poly_add2(p1, p2):
a= p1[0] + p2[0]
b= p1[1] + p2[1]
c= p1[2] + p2[2]
return [a, b, c]
# the purpose of this function is to multiply the values inside the list (like a polynomial) by using the distrib... | true |
18d665eba87ae845d1184dd5a6a59dbd81a00286 | the-last-question/team7_pythonWorkbook | /Imperial Volume.py | 1,838 | 4.59375 | 5 | # Write a function that expresses an imperial volume using the largest units possible. The function will take the
# number of units as its first parameter, and the unit of measure (cup, tablespoon or teaspoon) as its second
# parameter. Return a string representing the measure using the largest possible units as the ... | true |
82cda6b117d2bc918b8d675313db9f7a5b6314ba | sunyumail93/Python3_StepByStep | /Day02_IfElse/Day02_IfElse.py | 653 | 4.15625 | 4 | #!/usr/bin/python3
#Day02_IfElse.py
#Aim: Solve the missing/extra input problem using if/else statement. Use internal function len(), print()
#This sys package communicate Python with terminal
import sys
Total_Argument=len(sys.argv)-1 #sys.argv[0] is the script name
if Total_Argument == 0:
print("Please input two... | true |
484fdb72be152019168cdf842edc31148ce5eb85 | RiqueBR/refreshed-python | /Monday/basics.py | 1,157 | 4.53125 | 5 | # You can write comments using a # (hash) or a block with """ (three double quotes)
# Module is a different name for a file
# Variables are also called identifiers
a = 7
print(a)
"""
Python won't have major issues with differentiate whole interger and floats
"""
b = 9.3
print(int(b)) # Take the interger of a float (... | true |
a092b1273accd648d829f7b7f8321e3469d75f66 | romanPashnitskyi/PythonProjects | /task3_3.py | 281 | 4.125 | 4 | #! /usr/bin/env python3
import sys
weight = input("Введіть Вашу вагу в кг: ")
height = input("Введіть Ваш зріст в метрах : ")
weight = float(weight)
height = float(height)
print('Індекс Маси Тіла - ', + weight / height** 2)
| false |
f45aa98e5010666f1b0b16da119452b43db0de09 | chgeo2000/Turtle-Racing | /main.py | 2,104 | 4.28125 | 4 | import turtle
import time
import random
WIDTH, HEIGHT = 500, 500
COLORS = ['red', 'green', 'blue', 'cyan', 'yellow', 'black', 'purple', 'pink']
def get_number_of_racers():
"""
This function asks the user for the number of racers
:return: int, number of racers
"""
while True:
... | true |
28b4020cbd612ffc2b7f16ac2ba44e39f5ff4ab8 | tomatchison/CTI | /P4LAB1_Atchison.py | 661 | 4.40625 | 4 | # Write a program using turtle to draw a triangle and a square with a for loop
# 25 Oct 2018
# CTI-110 P4T1a: Shapes
# Tom Atchison
# Draw a square and a triangle using turtle.
# Use a while loop or a for loop.
# Start turtle.
import turtle
# See turtle on screen.
wn=turtle.Screen()
# Give turtle optio... | true |
4a4300f301d976b8bb1b7a96e6727f12c501ec83 | tomatchison/CTI | /P4LAB3_Atchison.py | 737 | 4.1875 | 4 | # Create my initials using turtle
# 25 Oct 2018
# CTI-110 P4T1b: Initials
# Tom Atchison
# Start turtle.
import turtle
import random
# See turtle on screen.
wn=turtle.Screen()
wn.bgcolor("green")
# Give turtle optional name.
sid=turtle.Turtle()
sid.speed(20)
# Give turtle shape.
sid.shape ("turtle... | true |
54290f9350ad833ee6165b2715d5fdcca2e61b8c | mvanorder/forecast-forecast_old | /overalls.py | 1,095 | 4.125 | 4 | ''' general use functions and classes '''
def read_list_from_file(filename):
""" Read the zip codes list from the csv file.
:param filename: the name of the file
:type filename: sting
"""
with open(filename, "r") as z_list:
return z_list.read().strip().split(',')
def key_list(... | true |
f2d03a02a7e8c0beeb5ebdf2448a95c6d3cbc18a | zzzzzzzlmy/MyLeetCode | /125. Valid Palindrome.py | 440 | 4.125 | 4 | '''
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a palindrome.
"race a car" is not a palindrome.
'''
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype:... | true |
50abfc53edeb131cbd64dcfca42baca644c3b9c5 | Joshcosh/AutomateTheBoringStuffWithPython | /Lesson_15.py | 1,665 | 4.40625 | 4 | # %%
# 1 | methods and the index method
spam = ['hello', 'hi', 'howdy', 'heyas']
spam.index('hello') # the index method
spam.index('heyas')
spam.index('asdfasdf') # exception
# %%
# 2 | in the case a value apears more than once - the index() method returns the first item's index
spam = ['Zophie', 'Pooka', 'Fat-tail', ... | true |
39629ce760dc9f089ba7566febb9c1bfb2c60921 | Some7hing0riginal/lighthouse-data-notes | /Week_1/Day_2/challenge2.py | 1,305 | 4.3125 | 4 | """
#### Rules:
* Rock beats scissors
* Scissors beats paper
* Paper beats rock
#### Concepts Used
* Loops( for,while etc.)
* if else
#### Function Template
* def compare(user1_answer='rock',user2_answer='paper')
#### Error Handling
* If the user_answer input is anything other than 'rock','paper' or 'scissors' re... | true |
1e7499929fdbe5b458524329ec9b45230a0b31ac | zhast/LPTHW | /ex5.py | 635 | 4.46875 | 4 | name = 'Steven Z. Zhang'
age = 18
height = 180 # Centimeters
weight = 175 # Pounds
eyes = 'Dark Brown'
teeth = 'White'
hair = 'Brown'
# The f character in the function lets you plug in a variable with curly brackets
print(f"Let's talk about {name}.") # In this case, its name
print(f"He's {height} centimeters tall")
... | true |
ff13fde0d24c6d8b175496fe127cdee185588557 | MaleehaBhuiyan/pythonBasics | /notes_and_examples/o_two_d_lists_and_nested_loops.py | 1,053 | 4.125 | 4 | #2d lists and nested loops
number_grid = [
[1,2,3],
[4,5,6],
[7,8,9],
[0]
]
#selecting individual elements from the grid, this gets the number 1, goes by row and then column
print(number_grid[0][0])
#nested for loop to print out all the elements in this array
for row in number_grid: #this will o... | true |
20d57d8eab474dac7e2c0b4e79713cfea581dadc | MaleehaBhuiyan/pythonBasics | /notes_and_examples/c_strings.py | 791 | 4.28125 | 4 | #Working with strings
print("Giraffe Academy")
print("Giraffe\nAcademy")
print("Giraffe\"Academy")
print("Giraffe\Academy")
phrase = "Giraffe Academy"
print(phrase + " is cool")
phrase = "Giraffe Academy"
print(phrase.lower())
phrase = "Giraffe Academy"
print(phrase.upper())
phrase = "Giraffe Academy"
print(phr... | false |
e76afe86418c782f16baf1d54a22b66254bb9fd7 | kjmjr/Python | /python/prime2.py | 513 | 4.25 | 4 | #Kevin McAdoo
#2-1-2018
#Purpose: List of prime numbers
#number is the variable for entering input
number = int(input('Enter a number and the computer will determine if it is prime: '))
#the for loop that tests if the input is prime
for x in range (2, number, x - 1):
if (number % x != 0):
print (nu... | true |
cf5de27304a6ae16c9219c902bba602979340412 | kjmjr/Python | /python/list_processing.py | 807 | 4.25 | 4 | #Kevin McAdoo
#2-21-2018
#Chapter 7 homework
print ('List of random numbers: ')
#list of random numbers
myList = [22, 47, 71, 25, 28, 61, 79, 57, 89, 3, 29, 41, 99, 86, 75, 98, 4, 31, 22, 33]
print (myList)
def main():
#command for the max function
high = max(myList)
print ('Highest number: ',... | true |
6b461d8563f05832a796b79b4a84999447d98436 | kjmjr/Python | /algorithm_workbench_problems.py | 860 | 4.40625 | 4 | #Kevin McAdoo
#Purpose: Class assignment with if/else statements/ the use of and logical operators
#1-24-2018
#3. The and operator works as a logical operator for testing true/false statements
#where both statements have to be true or both statments have to be false
#4 The or operator works as another logical ... | true |
7300bf857322e6298d6f30e4b15affbcb752afe0 | kjmjr/Python | /python/Test 1.py | 949 | 4.125 | 4 | #Kevin McAdoo
#2-14-2018
#Test 1
#initializing that one kilometer is equal to 0.621 miles
one_kilo = 0.621
#the define main function is calling the def get_kilometers (): and def km_to_miles(): functions
def main():
#user inputs his number here and float means the number he/she uses does not have to be a w... | true |
85f2ba90389fb93c15f832f74166552bbbf44061 | praveenpmin/Python | /list1.py | 693 | 4.1875 | 4 | # Let us first create a list to demonstrate slicing
# lst contains all number from 1 to 10
lst = range(1, 11)
print (lst)
# below list has numbers from 2 to 5
lst1_5 = lst[1 : 5]
print (lst1_5)
# below list has numbers from 6 to 8
lst5_8 = lst[5 : 8]
print (lst5_8)
# below list has numbers from 2 to 10
lst1_ =... | false |
595d3f99cbe522aaaf59a724de0d202dd32bbd44 | praveenpmin/Python | /tuples.py | 1,370 | 4.46875 | 4 | # Creating non-empty tuples
# One way of creation
tup='Python','Techy'
print(tup)
# Another for doing the same
tup= ('Python','Techy')
print(tup)
# Code for concatenating to tuples
tuple1=(0,1,2,3)
tuple2=('Python','Techy')
# Concatenating two tuples
print(tuple1+tuple2)
# code fore creating nested loops
tuple3=(tup... | true |
1acd357b716e8b304581d59179941a769737576a | praveenpmin/Python | /conversion3.py | 570 | 4.3125 | 4 | # Python code to demonstrate Type conversion
# using dict(), complex(), str()
# initializing integers
a = 1
b = 2
# initializing tuple
tup = (('a', 1) ,('f', 2), ('g', 3))
# printing integer converting to complex number
c = complex(1,2)
print ("After converting integer to complex number : ",end="")
print (c)
#... | false |
d9aca0f48d29458fde3174259a840b5ccf535355 | praveenpmin/Python | /operatoverload1.py | 212 | 4.4375 | 4 | # Python program to show use of
# + operator for different purposes.
print(1 + 2)
# concatenate two strings
print("Geeks"+"For")
# Product two numbers
print(3 * 4)
# Repeat the String
print("Geeks"*4) | true |
c4b0602b03fedeef579efbb0a9694df624cf3b7c | praveenpmin/Python | /var4.py | 413 | 4.375 | 4 | a = 1
# Uses global because there is no local 'a'
def f():
print ('Inside f() : ', a)
# Variable 'a' is redefined as a local
def g():
a = 2
print ('Inside g() : ',a)
# Uses global keyword to modify global 'a'
def h():
global a
a = 3
print ('Inside h() : ',a)
# Global scope
print ... | false |
c74901d9e80c204115ead86d6377750fd6ca8609 | praveenpmin/Python | /listmethod2.py | 521 | 4.71875 | 5 | # Python code to demonstrate the working of
# sort() and reverse()
# initializing list
lis = [2, 1, 3, 5, 3, 8]
# using sort() to sort the list
lis.sort()
# displaying list after sorting
print ("List elements after sorting are : ", end="")
for i in range(0, len(lis)):
print(lis[i], end=" ")
print("\r")... | true |
6fa1af52a4965d5b74ed3274a2b0f2e7aafe7192 | praveenpmin/Python | /inherit1.py | 715 | 4.34375 | 4 | # Python code to demonstrate how parent constructors
# are called.
# parent class
class Person( object ):
# __init__ is known as the constructor
def __init__(self, name, idnumber):
self.name = name
self.idnumber = idnumber
def display(self):
print(self.name)
print(self.idnumber)
#... | true |
c2f887c4e61320c71677beab7e8b81ce285cf8e8 | praveenpmin/Python | /Array1.py | 2,642 | 4.46875 | 4 | # Python code to demonstrate the working of array
import array
# Initializing array with array values
arr=array.array('i',[1,2,3])
# Printing original array
print("The new created array is:",end="")
for i in range(0,3):
print(arr[i],end="")
print("\r")
# using append to insert value to end
arr.append(4)
# prin... | true |
6b00144868f5c61dcbc1dc8ca8b5263c7ef887ba | LanYehou/shared_by_Lan | /python/test.py | 1,730 | 4.21875 | 4 | def theReturn():
def funx(x): #function funx,
def funy(y): #function funy is in function funx.
return(x*y) #return x*y means now the function funy(y)=x*y . if you use print(funy(y)) you will get the answer of x*y .
return(funy(2)) #now in funy(y) , y=2 . So funx(x) = ... | false |
ccd1785e19f8fbc77c086eee6c3e774ef363d7ef | HosseinSheikhi/navigation2_stack | /ceiling_segmentation/ceiling_segmentation/UNET/VGG16/VGGBlk.py | 2,915 | 4.34375 | 4 | """
Effectively, the Layer class corresponds to what we refer to in the literature as a "layer" (as in "convolution layer"
or "recurrent layer") or as a "block" (as in "ResNet block" or "Inception block").
Meanwhile, the Model class corresponds to what is referred to in the literature as a "UNET"
(as in "deep learning ... | true |
da3a66bfcd0abf09460b271250091c659e82f619 | prasantakumarsethi/python | /Python Probs/List_Mutability.py | 436 | 4.125 | 4 | #to show list and Dictionary are mutable or not
# list
Fruits = ["Apple","Banana","Mango","Strawberry","Watermelon"]
print(id(Fruits))
print(Fruits)
Vegetables = Fruits
Vegetables[1]='Orange'
print(id(Vegetables))
print(Vegetables)
#dictonary
Fruits = {1:"Apple",2:"Banana",3:"Mango",4:"Strawberry",5:"Watermelon"}
p... | false |
179a2434a5f74bc68dc20538808418e7de18da2c | KiteQzioom/Module-4.2 | /Module 4.2.py | 372 | 4.1875 | 4 |
def isPalindrome(word):
length = len(word)
inv_word = word[::-1]
if word == inv_word:
answer = True
else:
answer = False
print(answer)
"""
The function isPalindrome takes an input of a string and checks if it is a palindrome. It outputs the answer in boolean as True or False... | true |
914c64272ef4e56be777df07db7ace7768cf30fc | AsemAntar/codewars_problems | /add_binary/add_binary.py | 899 | 4.28125 | 4 | def add_binary(a, b):
sum = a + b
return bin(sum)[2:]
'''
====================================================================================================
- writing the same function without the builtin bin method.
- Here we will follow a brute force approach.
- we follow the following method:
--> divide ... | true |
dd41527eebb329e606afa1c55db40f304c5124f1 | AsemAntar/codewars_problems | /create_phone_number/phone_number.py | 1,033 | 4.25 | 4 | # Author: Asem Antar Abdesamee
# Problem Description:
"""
Write a function that accepts an array of 10 integers (between 0 and 9),
that returns a string of those numbers in the form of a phone number.
Example: create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) --> (123) 456-7890
"""
'''
============================... | true |
e199f17d58cb5333de0ee06c197899d94fdafa47 | Kailashw/HackerRank_Python | /Day 25.py | 339 | 4.1875 | 4 | import math
def is_prime(n):
if n == 2:
return 'Prime'
if n % 2 == 0 or n < 2:
return 'Not prime'
for j in range(3, int(math.sqrt(n)) + 1):
if n % j == 0:
return 'Not prime'
return 'Prime'
n = int(input())
for i in range(n):
number = int(input())
print(is_pr... | false |
b556ded22fa9b378b0352bde27a02cf8ba3d5187 | ege-erdogan/comp125-jam-session-01 | /11_10/problem_07.py | 495 | 4.15625 | 4 | '''
COMP 125 - Programming Jam Session #1
November 9-10-11, 2020
-- Problem 7 --
Given a positive integer n, assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.)
'''
import math
n = 6
is_prime = True
if n != 2 and n % 2 == 0:
is_prime = False
... | false |
8dc831b049dd861d1cf468b8a971833b6d1659fa | ege-erdogan/comp125-jam-session-01 | /solutions/problem_07.py | 761 | 4.21875 | 4 | '''
COMP 125 - Programming Jam Session #1
November 9-10-11, 2020
-- Problem 7 --
Given a positive integer n, assign True to is_prime if n has no factors other than 1 and itself. (Remember, m is a factor of n if m divides n evenly.)
'''
import math
n = 5
is_prime = True
# There is a whole literature of primality test... | true |
1cb1efd306622329b3895df8777b7f5feffb8d61 | amanbhal/ImportantQuestions | /InsertionSort.py | 319 | 4.1875 | 4 | """
Implement Insertion Sort on an array.
"""
def insertionSort(arr):
for i in range(1,len(arr)):
j = i
while(j>0 and arr[j]<arr[j-1]):
print i,j,
arr[j], arr[j-1] = arr[j-1], arr[j]
j -= 1
print arr
return arr
print insertionSort([6,5,4,3,2,1]) | false |
b7f6dfb5b8cff9d58efcdfa21259ff7a35f6231c | OyvindSabo/Ardoq-Coding-Test | /1/HighestProduct.py | 2,834 | 4.40625 | 4 | #Given a list of integers, this method returns the highest product between 3 of those numbers.
#If the list has fewer than three integers, the method returns the product of all of the elements in the list.
def highestProduct(intList):
negativeList = []
positiveList = []
for integer in sorted(intList):
if i... | true |
eb85fed448859e906df0baceda09beee9ce16d15 | HaNuNa42/pythonDersleri-Izerakademi | /python kamp notları/while.py | 344 | 4.15625 | 4 | # while
number = 0
while number < 6:
print(number)
number += 1
if number == 5:
break
if number == 3:
continue
print("hello world")
print("************************")
for number in range(0,6):
if number == 5:
break
if number == 3:
continue
... | true |
a01d518ebf69b684987a43d8c0cd24991d864ad9 | PzcMist/python-exercise | /ex3.py | 1,167 | 4.65625 | 5 | print("I will now count my chickens:")
#在屏幕上打印出I will now count my chickens:
print("Hens", 25 + 30 / 6)
#在屏幕上打印Hens,同时计算(先除在家,/表示全部除尽)打印
print("Roosters", 100 - 25 * 3 % 4)
#打印Roosters,同时计算(先*在 % 最后计算-)
print("Now I will count the eggs:")
#在屏幕上打印Now I will count the eggs:
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 +... | false |
b97dd0be85ef222c68510a16797d4c76e6f43a9d | Biwoco-Playground/Learn-Docker_VNL | /Cookbook/Chapter1/1-12.py | 386 | 4.28125 | 4 | from collections import Counter
words = [
'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes',
'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the',
'eyes', "don't", 'look', 'around', 'the', 'eyes', 'look', 'into',
'my', 'eyes', "you're", 'under'
]
print(Counter(words))
print('In... | false |
903fa4b1f636803dd1f0d5459926a97e53207380 | MingjuiLee/ML_PracticeProjects | /02_SimpleLinearRegression/main.py | 1,595 | 4.125 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
# Import dataset
dataset = pd.read_csv('Salary_Data.csv')
print(dataset.info()) # check if there is missing value
X = dataset.iloc[:, :-1].valu... | true |
7fc45fdb496f88a3d9737b2d6ff20b7f77d9ca50 | 4GeeksAcademy/master-python-exercises | /exercises/013-sum_of_digits/solution.hide.py | 296 | 4.375 | 4 | #Complete the function "digits_sum" so that it prints the sum of a three digit number.
def digits_sum(num):
aux = 0
for x in str(num):
aux= aux+int(x)
return aux
#Invoke the function with any three-digit-number
#You can try other three-digit numbers if you want
print(digits_sum(123)) | true |
0627bc29400b783ed5bf32bd83ba5de53b3e152d | bjarki88/Projects | /prof1.py | 525 | 4.15625 | 4 | #secs = int(input("Input seconds: ")) # do not change this line
#hours = secs//(60*60)
#secs_remain = secs % 3600
#minutes = secs_remain // 60
#secs_remain2 = secs % 60
#seconds = secs_remain2
#print(hours,":",minutes,":",seconds) # do not change this line
max_int = 0
num_int = int(input("Input a number: ")) # D... | true |
20198edc2742d160db704a992dd544f1627d5ac4 | B-Tech-AI-Python/Class-assignments | /sem-4/Lab1_12_21/sets.py | 680 | 4.28125 | 4 | print("\n--- Create a set ---")
set_one = {1, 3, 5, 7}
print(set_one)
print(type(set_one))
print("\n--- Add member(s) in a set ---")
set_two = {2, 3, 5, 7}
print(set_two)
print("Adding 11 to current set:", end=" ")
set_two.add(11)
print(set_two)
print(type(set_two))
print("\n--- Remove item(s) from a set ---")
to_r... | true |
43d015b115f8b396ef4fc919ff2ccfa4b737ac97 | B-Tech-AI-Python/Class-assignments | /sem-3/Lab_File/exp_1.py | 892 | 4.21875 | 4 | # %%
# WAP to understand the different basic data types and expressions
print("Integer")
int_num = 1
print(int_num, "is", type(int_num))
# %%
print("Float")
float_num = 1.0
print(float_num, "is", type(float_num))
# %%
print("Complex Number")
complex_num = 1 + 8j
print(complex_num, "is", type(complex_num))
# %%
print... | true |
ff3134c834c903218aafa07dc0961f138b426015 | Bhavyasribilluri/python | /nom.py | 219 | 4.46875 | 4 | #to find largest number
list= []
num= int(input("Enter number of elements in the list:"))
for i in range(1, num + 1):
ele = int(input("Enter elements: "))
list.append(ele)
print("Largest element is:", max(list)) | true |
af0ffc4ef074f2facdcdc90a0c5167dde4caea67 | Isisr/assignmentOrganizer | /assignmentOrganizer.py | 1,597 | 4.34375 | 4 | '''
Created on Feb 10, 2019
@author: ITAUser
ALGORTHM:
1) Make a .json text file that will store our assignments
2) IMport our .json file into our code
3) Create user input for finding assignments
4) Find the users assignments in our data
-If the users input is in our data
-The users input isn't in our data
'... | true |
9b647e7adeb4698353ab3169bdba4af0ad23a426 | alextodireanu/algorithms | /bubble_sort.py | 410 | 4.375 | 4 | # bubble sort algorithm
def bubble_sort(bs_list):
"""Method to bubble sort a given list"""
n = len(bs_list)
# reading all the elements in our list
for i in range(n-1):
for j in range(n-i-1):
if bs_list[j] > bs_list[j+1]:
bs_list[j], bs_list[j+1] = bs_list[j+1], bs_li... | false |
8ac0ff3826a01324a3e7501a460c037c750ef9bd | diegord13/programas | /Retos/sesiones/sesion10/sesion10.py | 2,669 | 4.40625 | 4 | """
Funciones
La verdad es que hemos venido trabajando con funciones desde que empezamos con archivos .py
En Python, definimos una función con la siguiente estructura
def funcion(parametros)
Recuerda que los parametros son opcionales!
"""
def suma(a,b):
print(a+b)
#suma(3,4)
#Actividad 1
def caja():
... | false |
8aedac9cc35461ba6258502c0d04b84c98760bc7 | Mybro1968/AWS | /Python/02Basics/example/03Number.py | 342 | 4.1875 | 4 | from decimal import *
number1 = int(input("What is the number to be divided? "))
number2 = int(input("What is the number to divided by? "))
print(number1, " / ", number2, " = ", int(number1 / number2))
print(number1, " / ", number2, " = ", float(number1 / number2))
print(number1, " / ", number2, " = ", Decimal... | true |
0f2920f5267dcc5b41d469e363af037264c5d342 | Mybro1968/AWS | /Python/05Files/Exercise/01WriteTeams.py | 392 | 4.125 | 4 | # Purpose : writes a file with input for up to 5 names
file = open("teams.txt","w")
count = int(input("how many teams would you like to enter? "))
#team_name = input("Please enter a team name: ")
for n in range(count):
if count !=0:
team_name = input("Please enter a team name: ") + "\n"
... | true |
6b06b17601db13468cb668d63df1582e33c5de0b | zzwei1/Python-Fuzzy | /Python-Tutorial/Numerology.py | 2,629 | 4.15625 | 4 | #!usr/bin/python
# Function to take input from Person
def input_name():
""" ()->int
Returns sum of all the alphabets of name
"""
First_name= input("Enter the first Name")
Middle_name= input("Enter the middle Name")
Last_name= input("Enter the last Name")
count1=count_string(First_name)
... | true |
20b5b26e28989a0bd3d98cdcbeaf3583351eeef5 | jkatem/Python_Practice | /FindPrimeFactors.py | 431 | 4.15625 | 4 |
# 1. Find prime factorization of a given number.
# function should take in one parameter, integer
# Returns a list containing all of its prime factors
def get_prime_factors(int):
factors = list()
divisor = 2
while(divisor <= int):
if (int % divisor) == 0:
factors.append(divisor)
... | true |
a677d4055dbe59dec016fe09756f57176d7ddc6c | amanmishra98/python-programs | /assign/14-class object/class object10.py | 577 | 4.1875 | 4 | #2.define a class Account with static variable rate_of_interest.instance variable
#balance and accountno. Make function to set values in instance object of account
#,show balance,show rate_of_interest,withdraw and deposite.
class Account:
rate_of_interest=eval(input("enter rate of interest\n"))
def info(se... | true |
8265c18a5344c85d76ca67601d613501cd660841 | alessandraburckhalter/Exercises | /ex-07-land-control.py | 498 | 4.1875 | 4 | # Task: Make a program that has a function that takes the dimensions of a rectangular land (width and length) and shows the land area.
print("--" * 20)
print(" LAND CONTROL ")
print("--" * 20)
# Create a function to calculate the land area
def landArea(width, length):
times = width * length
prin... | true |
5b8fe72fd81b5ebb09d48774e3259dc5b69c05d7 | bazerk/katas | /tree_to_list/tree_to_list.py | 939 | 4.25 | 4 | def print_tree(node):
if not node:
return
print node.value
print_tree(node.left)
print_tree(node.right)
def print_list(node, forwards=True):
while node is not None:
print node.value
node = node.right if forwards else node.left
def transform_to_list(node, prev=None):
i... | true |
bd3a39f97ab581ce0a090408c6d63039e0df80a6 | JorgeAntonioZunigaRojas/python | /practica_generadores_vs_funciones.py | 1,573 | 4.21875 | 4 | '''
def funcion_generar_numeros_pares(limite):
numero=1
numeros_pares=[]
while numero<limite:
numeros_pares.append(numero*2)
numero=numero+1
return numeros_pares
resultado=funcion_generar_numeros_pares(10)
print(resultado)
'''
# La diferencia entre un generador y una funcion es
# --> f... | false |
5191bf3ef7658a74fb8ad5a4d8f42b3f7c4052d7 | rudresh-poojari/my-captain-assingments | /circle_area.py | 323 | 4.125 | 4 | r = float(input("enter the radius of the circle : "))
area = 3.14159265359*r**2
print("the area of thr circlr with radius ",r,"is : ",area)
# output :
# C:\Users\rudre\OneDrive\Desktop\pythonmc>circle_area.py
# enter the radius of the circle : 1.1
# the area of thr circlr with radius 1.1 is : 3.80132711084390... | false |
2928aac960286ff38dae1ca85e50c0d0ba653111 | cvhs-cs-2017/practice-exam-IMissHarambe | /Loops.py | 282 | 4.34375 | 4 | """Use a loop to make a turtle draw a shape that is has at least 100 sides and
that shows symmetry. The entire shape must fit inside the screen"""
import turtle
meme = turtle.Turtle()
for i in range (100):
meme.forward(1)
meme.right(3.3)
input()
| true |
fbcc409e7bdf235598c1db86b34f4a5ad4b146b5 | furtiveJack/Outils_logiciels | /projet/src/utils.py | 1,768 | 4.21875 | 4 | from enum import Enum
from typing import Optional
"""
Utility methods and variables for the game.
"""
# Height of the window (in px)
HEIGHT = 1000
# Width of the window (in px)
WIDTH = 1000
# Shift from the side of the window
ORIGIN = 20
NONE = 0
H_WALL = 1
V_WALL = 2
C_WALL = 3
MINO = 4
class CharacterType(Enum):
... | true |
dc657b9020a4d2635cf85d2a00f8b4cb928c6a37 | arayariquelmes/curso_python_abierto | /18_ejemplo_while.py | 484 | 4.15625 | 4 | #import os
#Ejemplos de uso del ciclo while
#1. Ciclo que se repite una cantidad indeterminada de veces
res="si"
while res == "si":
print("Bienvenido al programa!")
res = input("Desea continuar?")
#Esto limpia la pantalla
#os.system('clear')
print("Gracias por utilizar el super programa más util del m... | false |
69422e8bcf009b6bff2355220506721adc178cad | JasmineEllaine/fit1008-cpp-labs | /3-lab/task1_a.py | 1,180 | 4.25 | 4 | # Task 1a
# Read input from user (int greater than 1582)
# If leap year print - is a leap year
# Else print - is not a leap year
def main():
""" Asks for year input and prints response accordingly
Args:
None
Returns:
None
Raises:
No Exceptions
Preconditions:
... | true |
bec90b0361b19f66e15bfef6d5abacd2bddc9970 | msm17b019/Project | /DSA/Bubble_Sort.py | 677 | 4.1875 | 4 | def bubble_sort(elements):
size=len(elements)
swapped=False # if no swapping take place in iteration,it means elements are sorted.
for i in range(size-1):
for j in range(size-1-i): # (size-i-1) as last element in every iteration is getting sorted.
if elements[j]>elements[j+1]:
... | true |
d80c6860c1560d77f5375136529dc5dfbfdfd709 | OusmaneCisse/tableMulti_anneeBiss | /tableMulti_anneeBiss/table_de_multiplication.py | 579 | 4.15625 | 4 | """
Cette fonction permet d'afficher la table de multiplication en fonction d'un nombre enter au clavier.
Auteur: Ousmane CISSE
Date: 05/12/2020
"""
__version__ = "0.0.1"
#Creation de la fonction
def table_de_multiplication():
#Recupération de la valeur
n = int(input("Veuillez entrer un nombre:... | false |
bb05a9044f8fdaca1ca78ec9d7f63f2840cc9866 | hampusrosvall/leetcode | /merge_linked_lists.py | 2,340 | 4.28125 | 4 | """
P C
l1: 1 -> 6 -> 7 -> 8
N
l2: 2 -> 3 -> 4 -> 5 -> 9 -> 10
The idea is to insert the nodes of the second linked list into the first one.
In order to perform this we keep track of three pointers:
1) prevNode (points to the previous node in the insertion list)
2) currentNode (points... | true |
b9a617f0880e2997d7319464c1c7c5aa7ff3395e | blueclowd/leetCode | /python/1042-Flower_planting_with_no_adjacent.py | 1,257 | 4.1875 | 4 | '''
Description:
You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers.
paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y.
Also, there is no garden that has more than 3 paths coming into or leaving it.
Your task is to choose a flower ... | true |
0b23ebf4c19a7d6dc6fbea5e184b61d1d6116854 | blueclowd/leetCode | /python/0101-Symmetric_tree.py | 1,458 | 4.15625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
# Iterative
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if not root:
return True
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.