Python Primer
Recently I’ve started to play with Python. I’ve heard a lot about this language before. Recently I’ve just completed my ‘Hello World’ program 🙂
You can get Python from here. I use python’s interactive shell as well as PyDev plugin for Eclipse to write codes
#This is a comment #version 3.0 print("Hello World!"); #semicolon is not required but I use this
- Commenting code
#This is a comment
- Assigning values
x = 5 #5 is assigned to x print (x) #prints 5 print (type(x)) # outputs <class 'int'> x, y = 0, 1 x, y = y, x print(x,y) # prints 1, 0
- Conditions
#traditional conditions x , y = 10, 20 if x < y : print ('X is less than Y') # prints 'X is less than Y' #conditional expressions x, y = 0, 1 z = "less than" if x < y else "not less than" print (z) #prints 'less than'
- Writing a function
#defining a function def myFunc(): print('This is a function in python') #invoking the function myFunc() # prints 'This is a function in python'
- Writing a class
class Language: def __init__(self, name = 'Python'): #constructor self.name = name def showName(self): return self.name scripting = Language() #an instance of the Language class print(scripting.showName()) #as you've guessed :), it prints 'Python' procedural = Language('C') #another instance of the Language class print(procedural.showName()) #now it prints 'C' 🙂
- Getting Input from the User
hawkingsFound = input('Enter what hawkings found lately? :)') #prompts the user 'Enter what hawkings found lately? :)' , user enters 'girls are mysterious' print(hawkingsFound) # it prints 'girls are mysterious' 🙂
How to calculate the time required for a block of code in C/C++?
Here are a small code snippets with which you can calculate the execution time of a certain block of codes in C/C++.
#include <stdio.h> #include <time.h> #include <stdlib.h> clock_t startm, stopm; #define START if ( (startm = clock()) == -1) {printf("Error calling clock");exit(1);} #define STOP if ( (stopm = clock()) == -1) {printf("Error calling clock");exit(1);} #define PRINTTIME printf( "%6.3f seconds used by the processor.", ((double)stopm-startm)/CLOCKS_PER_SEC); int main() { START;//start the timer //code blocks which execution time will be counted begins here int n; for(n = 0; n<=65535; n++) { printf("%d\n", n); } //code blocks which execution time will be counted ends here STOP;//end the timer PRINTTIME;//print the time return 0; }
The program will print total 65536 numbers line by line and at the end it’ll print the total seconds e.g 5.109 seconds, it took to print the numbers
—–courtesy: http://kennethfinnegan.blogspot.com/2008/03/timing-events-in-c.html
Basic Programming Quiz 0010
Examine the code snippets given below—-
#include <stdio.h> int main() { char ch; while((ch = getchar()) != '\0') putchar(ch); return 0; }
What does the program display?
Look at another code snippets—-
#include <stdio.h> int main() { while( putchar(getchar( )) != '\0' ) ; return 0; }
Now, what does it display?
Is there any difference in program execution between these two code snippets?
Basic Programming Quiz 0001
Examine the code snippets given below—-
#include <stdio.h> int main() { int x; x = 10; if(x == 10) { int x; x = 99; printf("Inner x: %d\n", x); } printf("Outer x: %d\n", x); return 0; }
What does the program displays?
Neptune and Uranus may have oceans of diamonds!
[tweetmeme]
Scientists have said that the our solar system may have oceans of diamonds.According to ABC News, a new report has suggested that oceans of liquid diamond icebergs, could be floating on Neptune and Uranus.
The research is based on the first detailed measurements of the melting point of diamond.
“High-Speed” Networks Are No Faster Than “Low-Speed” Networks
[tweetmeme]
All computer networks operate at the same speed. They send and receive data at roughly 186,000 miles per second. So,what makes those wonderful “broadband” Internet connections seem so “fast”? After all,the transmission speed is limited by the laws of physics. The answer is that computer networks use various methods to represent data on the communications link. For example,the character “U” in my name could possibly be represented by a code of eight bits (binary 0s and 1s).
Knowing(2009)
[tweetmeme]Director:
Writers:
Ryne Douglas Pearson (screenplay) and
Juliet Snowden (screenplay)Release Date:
20 March 2009 (USA)
Tagline:
Knowing is Everything…Download Link(rmvb229mb):
গুগল ছাড়লো এন্ড্রয়েড ফোন
Big G (Google ) & T-Mobile stick together and release the first Android operated Phone. So, What the hell is that Android ? Aha! Its a Open Source mobile OS (like Symbian) by Google.
Check it out – http://code.google.com/android/
And for the Android Phone Specification goto – http://www.t-mobileg1.com/g1-android-details-leak.aspx
কী লগার এর হাত থেকে নিরাপদ থাকা
ইন্টারনেট ব্যাবহার করার সময় আমাদের সবারই অনেক ফরম পূরণ করতে হয়।পাসওয়ার্ড দেওয়ার দরকার হয়।এক ধরনের সফটওয়্যার আছে যেগুলো সিস্টেমে গোপনে অবস্থান করে এবং ইউজারের প্রতিটি কীস্ট্রোক লগ করে।
অনেক সময় সাইবার ক্যাফেতে আমাদের ব্রাউজ করতে হয়।সাইবার ক্যাফের পিসিগুলিতে এসব কি কী লগার সফটিয়্যার থাকতে পারে।একটি সফটওয়্যার ব্যাবহার করে আমরা এসব কী লগার বাইপাস করতে পারি।
সফটওয়্যারটির নাম Neo’s SafeKeys.
৭.০৬ কেবির এ সফটিয়্যারটি পেন ড্রাইভে বহনযোগ্য। সফটিয়্যারটি রান করলে একটি ছোট্ট মাউস বেসড কী বোর্ড স্ক্রীনে দেখা যাবে।তারপর কী বোর্ডে পাসওয়ার্ড ক্লিক করতে হবে।তারপর পাসওয়ার্ড সিলেক্ট করে ড্র্যাগ করে এনে আপনি যেখানে পাসওয়ার্ড দিতে চান সেখানে ছেড়ে দিতে হবে।
তাহলে আপনার ফরমের পাসওয়ার্ড ফিল্ডটি পূরণ হয়ে যাবে।এখান থেকে সফটওয়্যারটি ডাঊনলোড করে নিতে পারেন। এটি শুধু উইন্ডোজ–এ কাজ করে।
লেখাটি বিজ্ঞানী.কমে প্রকাশিত।
http://biggani.com/content/view/777/120/
Flash drives ready to jump in capacity
In the wake of a series of technical announcements from flash memory supplier SanDisk, larger-capacity solid-state drives are on the way.Flash memory is gaining as a replacement for hard drives in ultra-thin, ultra-small notebooks such as the MacBook Air and Asus Eee PC. Why? Flash uses less power, generates less heat, and has faster access times than hard drives. The Air, for example, offers a 64GB flash-based SSD as an option while the Eee PC is sold standard with flash storage.There is a big catch, though. High-capacity SSDs are expensive. Prohibitively so. The flash drive in the pricier $3,098 Air is the main culprit in the gaping $1,300 price difference with the lower-cost hard-drive model ($1,799).Update: Historically, flash memory has had
ওপেনসোর্সে ত্রিমাত্রিক পৃথিবী
গুগল্ এবং উইন্ডোজ লাইভ আমাদেরকে স্যাটেলাইট ব্যবহার করে ভূ-পৃষ্ঠের ত্রিমাত্রিক ছবি দেখায়। কিন্তু উক্ত প্রোগ্রামগুলি ছিলো শুধুমাত্র উইন্ডোজের জন্য আর সেজন্যই লিনাক্স ও ম্যাক ব্যবহারকারীরা একটু হলেও মন খারাপ করে ছিলো। এখন মন খারাপের দিন শেষ, কারন ওপেনসোর্সে উন্নত করা হয়েছে ভূ-পৃষ্ঠের ত্রিমাত্রিক ছবি দেখার সফটওয়্যার “গালা” বিশেষ করে ম্যাক এবং লিনাক্স ব্যবহারকারীদের জন্য। অনেকদিন থেকে গুগল্ আর্থ-এর উপর গবেষণা চালিয়ে তৈরী করা হয়েছে “গালা” সম্পুর্ন গুগল্-এর সার্ভারের উপর নির্ভর এই সফটওয়্যারটিতে তথ্য পরিবেশিত হয় গুগল্-এর মতই। উইন্ডোজ ব্যবহারকারীদের জন্য তেমন একটা মনোযোগ না দেয়ার জন্য উইন্ডোজ সংস্করণটি তেমন একটা ভালো নয়। তবে ম্যাক বা লিনাক্স ব্যবহারকারীরা http://gaia.serezhkin.com/ থেকে বিনামূল্যে গালা ডাউনলোড করে ব্যবহার করতে পারেন