1
General discussion / HApy NeW yEAr
« on: January 02, 2016, 08:23:15 pm »
Before the feel ends,... happy new year to all members hope to learn more this year!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

#try 1-127......(-ve)
#e.g.-13,-16,-17,-5 etc
print"-----------------------------------------------------"
print"Change from binary to one's and two's complement"
print"-----------------------------------------------------"
print"-----------------------------------------------------"
try:
result=[]
numb=input("Enter number:")
numb=abs(numb) #convert to positive number
except:
print("Digits only!")
else:
#get binary form you can use bin()....no biggy!
while numb!=0:
if numb%2==0:
result.append(0)
numb=numb//2
else:
result.append(1)
numb=numb//2
result.reverse() # get reversed form
sizeL=len(result)
#change to hex
if sizeL!=4:
size=8-sizeL
else:
size=4
for i in range(size):
result.insert(i,0)
print "(+)Binary form:",str(result).strip("]").strip("[").replace(",","")
#convert to one's complement
for i in range(8):
if result[i]==1:
result.pop(i)
result.insert(i,0)
else:
result.pop(i)
result.insert(i,1)
print "(+)One's complement:",str(result).strip("]").strip("[").replace(",","")
#convert to two's complement
twoC=range(8)
twoC.reverse()
for i in twoC:
if int(result[i])==1:
result.pop(i)
result.insert(i,0)
else:
result.pop(i)
result.insert(i,1)
break;
print "(+)Two's complement:",str(result).strip("]").strip("[").replace(",","")
print"-----------------------------------------------------"
print"\t\t\tEND"
print"-----------------------------------------------------"
try 1 to any 8bits form! .....but can be modified to have more bits.......
We had a challenge on that: https://evilzone.org/weekly-challenge/challenge-17-sieve-of-eratosthenes/Damn! did see that thread..... nicely done in c/c++ i guess i don't need to do it again!
print"*****************************************************"
print"\t\tSieve of Eratosthenes"
print"*****************************************************"
num=raw_input("||Enter a number:")
num=int(num)
result=range(2,num)
print"||-----------------------------"
print"||Prime numbers between 0-",num
print"||-----------------------------"
for i in result:
for j in result:
if j!=i and j%i==0:
result.pop(result.index(j))
print "||PRIME NUMBERS:",result
print"||------------------------------"
print"*****************************************************"
import java.util.Scanner;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
class PrimeNo{
public static void main(String... args){
int num;
Scanner input=new Scanner(System.in);
System.out.println("***********************************************");
System.out.println("\t\tSieve of Eratosthenes");
System.out.println("***********************************************");
System.out.println("||Find Prime Numbers");
System.out.println("||---------------------------------------------");
System.out.print("||Enter range:");
num=input.nextInt();
List<Integer> range=new CopyOnWriteArrayList<Integer>();
for(int i=2;i<num;i++)
{
range.add(i);
}
for(int i:range)
{
for(int j:range)
{
if(j!=i && j%i==0)
{
range.remove(range.indexOf(j));
}
}
}
System.out.println("||---------------------------------------------");
System.out.println("||---------------------------------------------");
System.out.println("||PRIME NOs:"+range);
System.out.println("||---------------------------------------------");
System.out.println("||---------------------------------------------");
System.out.println("***********************************************");
System.out.println("***********************************************");
}
}
..but i wanted to get a real insight of guys who were once python2 lovers but have now cheated with python3....What are the major programming difference other than print having brackets().And also why python3 and not python2....lets make this a final discussion on the topic
invalid query: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '-' at line 1
i have tried removing the -- but i don't get how??/
its not working.....