Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 356d73c

Browse files
Code
1 parent eb009ac commit 356d73c

File tree

100 files changed

+1261
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1261
-0
lines changed

‎32Bit_or_64Bit_Mode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Write a Python Program to determine if the python shell is executing in 32bit or 64bit mode on operating system.
2+
import struct
3+
print(struct.calcsize('P') * 8)

‎Accept_Positive_&_Subtract_Number.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'''Write a Python program that accept a positive number and subtract from this number the sum of its digits
2+
and so on. Continues this operation until the number is positive.'''
3+
4+
def repeat_times(n):
5+
s = 0
6+
n_str = str(n)
7+
while (n > 0):
8+
n -= sum([int(i) for i in list(n_str)])
9+
n_str = list(str(n))
10+
s += 1
11+
return s
12+
print(repeat_times(9))
13+
print(repeat_times(21))

‎Accept_Two_Integers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Write a python function to check whether a number is divisible by another number. accept two integers values from the user.
2+
def multiple(m, n):
3+
return True if m % n == 0 else False
4+
5+
print(multiple(20, 5))
6+
print(multiple(7, 2))

‎Accepts_Six_Numbers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write a Python Program that accepts six numbers as input and sorts them in descending Order.
2+
3+
'''Input: Input Consists of six numbers n1,n2,n3,n4,n5,n6 (-100000 ≤ n1,n2,n3,n4,n5,n6 ≤ 100000).
4+
The Six Numbers are Separated by a Space.'''
5+
6+
print("Input Six Integers: ")
7+
nums = list(map(int, input().split()))
8+
nums.sort()
9+
nums.reverse()
10+
print("After Sorting the said integers: ")
11+
print(*nums)

‎Actual_Module_Object.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Write a Python Program to Get the Actual Module Object for a Given Object.
2+
3+
from inspect import getmodule
4+
from math import sqrt
5+
print(getmodule(sqrt))

‎Add_2_Integers_without_using_'+'_opr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Write a Python Program to add two positive integers without using '+' operator.
2+
# Note: Use bitwise operations to add two numbers.
3+
4+
def add_without_plus_operator(a, b):
5+
while b != 0:
6+
data = a & b
7+
a = a ^ b
8+
b = data << 1
9+
return a
10+
print(add_without_plus_operator(2, 10))
11+
print(add_without_plus_operator(-20, 10))
12+
print(add_without_plus_operator(-10, -20))

‎Anonymous_Function.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Write a Python Program to Get Numbers Divisible by Fifteen From a List Using an Anonymous Function.
2+
3+
from unittest import result
4+
5+
6+
num_list = [45, 55, 60, 37, 100, 105, 220]
7+
8+
# Use Anonymous Function to Filter
9+
result = list(filter(lambda x: (x % 15 == 0), num_list))
10+
print('Numbers Divisible by 15 are', result)

‎Calculate_Run_Time.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write a python program to calculate the time runs (difference between start and current time) of a program.
2+
from timeit import default_timer
3+
def timer(n):
4+
start = default_timer()
5+
# some code here
6+
for row in range(0,n):
7+
print(row)
8+
print(default_timer() - start)
9+
10+
timer(5)
11+
timer(15)

‎Check_Installed_Python_Module.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write a Python Program to get a list of locally installed python modules.
2+
3+
import pkg_resources
4+
installed_packages = pkg_resources.working_set
5+
installed_packages_list = sorted(["%s==%s" %(i.key, i.version)
6+
for i in installed_packages])
7+
8+
for m in installed_packages_list:
9+
print(m)

‎Check_Integer_64_Bits.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Write a Python Program to Check Whether an Integer Fits in 64 Bits.
2+
3+
int_val = 30
4+
if int_val.bit_length() <= 63:
5+
print((-2 ** 63).bit_length())
6+
print((2 ** 63).bit_length())

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /