An example looking closer to class in python:
class Complex:
def __init__(self,realpart,imagpart):
self.r=realpart
self.i=imagpart
x=Complex(3.0,-4.5)
print x.r, x.i
You will get the output:
3.0 -4.5
I wrote about the solutions to some problems I found from programming and data analytics. They may help you on your work. Thank you.
ezoic
Wednesday, January 25, 2017
VNC, tele desktop
VNC, tele desktop, connect windows with linux, a virtual machine.
http://www.tightvnc.com/release-2.7.10.php
http://www.tightvnc.com/release-2.7.10.php
A good python book
A Primer on Scientific Programming with Python
Amazon link:
https://www.amazon.com/Scientific-Programming-Computational-Science-Engineering/dp/3642302920
Tuesday, January 24, 2017
How to switch to another disk and how to get ipconfig work on command prompt
How to switch to another disk and how to get ipconfig work on command prompt.
If you want to switch from C drive to G drive, you can try:
cd /d G:\
If you want to know your IP, you can use ipconfig. Sometimes it won't work. Try to go to windows\system32, and then type ipconfig.
C:\Windows\System32\ipconfig
If you want to switch from C drive to G drive, you can try:
cd /d G:\
If you want to know your IP, you can use ipconfig. Sometimes it won't work. Try to go to windows\system32, and then type ipconfig.
C:\Windows\System32\ipconfig
How to run a python class, and ow to run R script on linux
Here is a python class:
class Student:
def __init__(self, name, age):
self.name=name
self.age=age
def say_hello(self):
print(self.name, "say hello")
class Student:
def __init__(self, name, age):
self.name=name
self.age=age
def say_hello(self):
print(self.name, "say hello")
And, to run it, type the following in the same program:
alice=Student("Alice", 16)
alice.say_hello()
Do not forget the parenthesis.
Save the program as python1.py
And on linux run:
python python1.py
And you will see on the screen:
('Alice', 'say hello')
Here is another example:
class Base1:
def __init__(self,x,y):
self.x=x
self.y=y
def add1(self):
z=self.x+self.y
print(z)
def main():
foo=Base1(1,2)
foo.add1()
if __name__=="__main__":
main()
And you will see 3 was printed on screen.
To run an R program on linux, write an R program and save as rprog1.R
a=c(1,2,3)
for ( i in 1:3)
{ print(i)}
And run Rscript rprog1.R on linux, you will see:
[1] 1
[2] 2
[3] 3
Subscribe to:
Posts (Atom)
R is not a simple programming language, and it does better on reading excel files than python
R is not a simple programming language, and it does better on reading excel files than python . tried to read excel files to python and R. i...
-
I tried to commit script to bitbucket using sourcetree. I first cloned from bitbucket using SSH, and I got an error, "authentication ...
-
Previously, I wanted to install "script" on Atom to run PHP. And there was some problem, like the firewall. So I tried atom-runner...
-
How to learn SQL quickly? SQL is an easy database language to pull data from database, and make calculations etc. on it. It has many edit...
