Change file permission:
sudo chmod -R 777 /var/www
Class object:
file name media.py
##############
import webbrowser
class Movie():
def __init__(self, movie_title, movie_storyline, poster_image,
trailer_youtube):
self.title = movie_title
self.storyline = movie_storyline
self.poster = poster_image
self.trailer = trailer_youtube
def show_trailer(self):
webbrowser.open(self.trailer)
#############
trailller.py
import class_object
movie_story = class_object.Movie("Toy story", "something missing", "image url ",
"youtube.com")
print(movie_story.storyline)
movie_story.show_trailer()
###################
Read from url:
def read_web_page():
connection = urllib.request.urlopen(
"http://manozbiswas.blogspot.com/2016/02/nice-drawing-in-python.html")
output = connection.read()
print(output)
connection.close()
read_web_page()
#################
Read from file:
def readText():
quotes = open(r"C:\Users\manoz debnath\Desktop\py\hello.txt")
contents = quotes.read()
print(contents)
quotes.close()
readText()
######################
Drawing image:
import turtle
def drawSquare(some_turtle):
for i in range(1, 5):
some_turtle.forward(100)
some_turtle.right(90)
def drawArt():
window = turtle.Screen()
window.bgcolor("red")
# Create the turtle Brad -Draws square brad = turtle.Turtle()
brad.shape("turtle")
brad.color("yellow")
brad.speed(2)
for i in range(1,37):
drawSquare(brad)
brad.right(10)
#Create turtle Angie - Draws a circle
# angie = turtle.Turtle()
# angie.shape("arrow")
# angie.color("blue")
# angie.circle(100)
window.exitonclick()
drawArt()
#######################
Draw a square with a circle:
#################
import turtle def drawSquare(): window = turtle.Screen() window.bgcolor("red") brad = turtle.Turtle() brad.shape("turtle") brad.color("yellow") brad.speed(2) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) brad.forward(100) brad.right(90) angie = turtle.Turtle() angie.shape("arrow") angie.color("blue") angie.circle(100) window.exitonclick() drawSquare()
###################
![]() |
using System.Data.SqlClient;
class myConnection
{
public static SqlConnection GetConnection()
{
string str = "Data Source=MANOZ\\SQLEXPRESS;Initial Catalog=softworksbd;Integrated Security=True;";
SqlConnection con = new SqlConnection(str);
con.Open();
return con;
}
}
#include <iostream>
using namespace std;
int main() {
float n1, n2, n3;
cout << "Enter three numbers: ";
cin >> n1 >> n2 >> n3;
if (n1 >= n2) {
if (n1 >= n3) {
cout << "Largest number: " << n1;
}
else {
cout << "Largest number: " << n3;
}
}
else {
if (n2 >= n3) {
cout << "Largest number: " << n2;
}
else {
cout << "Largest number: " << n3;
}
}
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int num, n, div, p;
printf("Enter any number: ");
scanf("%d", &num);
for(n = 2; n <= num; n++)
{
for(div = 2; div < n; div++)
{
if(n % div == 0)
{
p = 0;
break;
}
p = 1;
}
if(p)
printf("%d ",n);
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int i, n, factorial = 1;
cout<<"Enter a positive integer: ";
cin>>n;
for (i = 1; i <= n; ++i) {
factorial *= i; // factorial = factorial * i;
}
cout<< "Factorial of "<<n<<" = "<<factorial;
return 0;
}
//Using recursion
#include<iostream> using namespace std; int main(){ int n, first = 0, second = 1, third; cout<< "enter the number of terms " << endl; cin >> n; cout << "first "<< n << " fibonaccy series"<< endl; for(int i = 1; i <= n ; i++){ if(i <= 1){ third = i; } else{ third = first + second; first = second; second = third; } cout << third << " "; } return 0; }
friend
keyword.friend
:}