Wednesday, 27 November 2019

Write Python program for sub strings

Method #1 : Using list comprehension + string slicing

# Python3 code to demonstrate working of
# Get all substrings of string
# Using list comprehension + string slicing 
# initializing string
test_str = "Geeks"

# printing original string
print("The original string is : " + str(test_str)) 

# Get all substrings of string
# Using list comprehension + string slicing
res = [test_str[i: j] for i in range(len(test_str))for j in range(i + 1, len(test_str) + 1)]

# printing result
print("All substrings of string are : " + str(res))

Output
== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/x.py ==
The original string is : Geeks
All substrings of string are : ['G', 'Ge', 'Gee', 'Geek', 'Geeks', 'e', 'ee', 'eek', 'eeks', 'e', 'ek', 'eks', 'k', 'ks', 's']





# Python3 code to demonstrate working of
# Get all substrings of string
# Using itertools.combinations()
from itertools import combinations
 
# initializing string 
test_str = "Geeks"
 
# printing original string 
print("The original string is : " + str(test_str))
 
# Get all substrings of string
# Using itertools.combinations()
res = [test_str[x:y] for x, y in combinations(range(len(test_str) + 1), r = 2)]
 
# printing result 
print("All substrings of string are : " + str(res))

Tuesday, 26 November 2019

Write a algorithm and python program for string concatenation

# Program-1
>>> 'a' + 'b' + 'c'

Output
'abc'

# program-2
>>> 'do' * 2

Output
'dodo'

# Program-3
>>> orig_string = 'Hello'
>>> orig_string + ', world'
Output
'Hello, world'

>>> orig_string = 'Hello'
>>> orig_string
Output
'Hello'

>>> full_sentence = orig_string + ', world'
>>> full_sentence
'Hello, world'




Sunday, 24 November 2019

11th Python program Compare strings

Python string comparison is performed using the characters in both strings. The characters in both strings are compared one by one. When different characters are found then their Unicode value is compared. The character with lower Unicode value is considered to be smaller.


#A  Program

fruit1 = 'Apple'
print(fruit1 == 'Apple')
print(fruit1 != 'Apple')
print(fruit1 < 'Apple')
print(fruit1 > 'Apple')
print(fruit1 <= 'Apple')
print(fruit1 >= 'Apple')

Output
== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/t.py ==
True
False
False
False
True
True



#B Program
print('apple' == 'Apple')
print('apple' > 'Apple')
print('A unicode is', ord('A'), ',a unicode is', ord('a'))


Output
== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/t.py ==
False
True
A unicode is 65 ,a unicode is 97

#Note: ord() function to print the Unicode code point value of the characters.

11th python: Traversing string using for, range function and slice operator

# A
# Python Program for string traversing:
 #Using for loop to traverse over a string in Python

string_to_trav = "Data Science"
for char in string_to_trav:
    print(char)

Output
>>>
== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/t.py ==
D
a
t
a

S
c
i
e
n
c
e

#B
# Using range() to traverse over a string in Python

string_to_trav = "Data Science"
for char_index in range(len(string_to_trav)):
   print(string_to_trav[char_index])

Output
>>>
== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/t.py ==
D
a
t
a

S
c
i
e
n
c
e


#C
# Using slice [] operator to traverse over a string partially

string_to_trav = "Python Data Science"
for char in string_to_trav[0 : 6 : 1]:
   print(char)

== RESTART: C:/Users/Student/AppData/Local/Programs/Python/Python37-32/t.py ==
P
y
t
h
o
n

Friday, 15 November 2019

Write a Recursive Python program with function BinarySearch(Arr,L,R,X) to search the given element X to be searched from the List Arr having R elements where L represents lower bound and R represents upper bound.

def binarysearch(Arr,L,R,X):
    if R>=L:
        mid=L+(R-L)//2
        if Arr[mid]==X:
            return mid
        elif Arr[mid]>X:
            return binarysearch(Arr,L,mid-1,X)
        else:
            return binarysearch(Arr,mid+1,R,X)
    else:
        return-1


#main program   
Arr=[2,3,4,10,40]
X=int(input("enter element to be searched : "))
result=binarysearch(Arr,0,len(Arr)-1,X)

if result!=-1:
    print("element is present at index ",result)
else:
    print("element is not present in array ")


Output

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
============ RESTART: C:\Users\acer\Desktop\nsp\bimary search.py ============
enter element to be searched : 4
element is present at index  2
>>>
============ RESTART: C:\Users\acer\Desktop\nsp\bimary search.py ============
enter element to be searched : 40
element is present at index  4
>>>
=========== RESTART: C:/Users/acer/Desktop/nsp/bimary search-c.py ===========
enter element to be searched : 3
element is present at index  1
>>> 

Thursday, 14 November 2019

Write a Python program with method/function DISPLAYWORDS() to read lines from a text file STORY.TXT, and display those words, which are less than 4 characters.

def displayword():
     file=open("D:\story.txt")
     line=file.read()
     c=0
     word=line.split()
     for w in word:
          if len(w)<4:
               print(w)
     file.close

#main program
displayword()

input
file name: story.txt

then he stooped and 
learned his head against the
wall and without a word he made
a gesture to us with 
his hands.

output
============== RESTART: C:/Users/Student/Desktop/12cs/fi-22.py ==============
he
and
his
the
and
a
he
a
to
us
his
>>> 

Write a Python program with function to count the number of lines in a text file ‘ 'STORY.TXT’ which is starting with an alphabet ‘A’.

def countlines():
     file=open("D:\story.txt.txt")
     lines=file.readlines()
     count=0
     for word in lines:
          if word[0]=="A" or word[0]=="a":
               count=count+1
     print("total lines",count)
     file.close

#main program
countlines()

Input
file name:  story.txt

abcdefoiioioio
h8uhyhy8
Ai9hpu
u8y8887
a9j-j8okjioij


output

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============== RESTART: C:/Users/Student/Desktop/12cs/fi-21.py ==============
total lines 3
>>> 

Sunday, 10 November 2019

Write a algorithm and python function program to search an a element in the tupple(linear search)


# Search function with parameter elements name
# and the value to be searched
def search(Tuple,n):
 
    for i in range(len(Tuple)):
        if Tuple[i] == n:
            return True
    return False


# Main program 
# list which contains both string and numbers in a tupple.
Tuple= (1, 2, 'sachin', 4, 'Geeks', 6)
n = 'sachin'
 
if search(Tuple, n):
    print("Found")
else:
    print("Not Found")

output
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
== RESTART: C:/Users/student/AppData/Local/Programs/Python/Python36-32/q.py ==
sachin
Found
>>>

>>>
== RESTART: C:/Users/student/AppData/Local/Programs/Python/Python36-32/q.py ==
5
Not Found
>>>

Thursday, 7 November 2019

11TH CS H.Y EXAMINATION 2019(REGIONAL) QUESTION PAPER


QUESTION PAPER: CLICK HERE

MARKING SCHEME(REFERENCE ONLY): CLICK HERE

12th CS November-2019 Blue print -35 marks


I Django Based application GET and POST request -5 mark

II Interface python  with an SQL database - 5 mark

III SQL Commands: aggregate functions - 5 marks

IV Society, Law and Ethics - 20 marks

Sunday, 3 November 2019

Society, Law and Ethics-SLE-2



 The law may be understood as the systematic set of universally accepted rules and regulation created by an appropriate authority such as government, which may be regional, national, international, etc. It is used to govern the action and behavior of the members and can be enforced, by imposing penalties.

Ethics are the principles that guide a person or society, created to decide what is good or bad, right or wrong, in a given situation. It regulates a person’s behavior or conduct and helps an individual in living a good life, by applying the moral rules and guidelines.

intellectual property rights

A right that is had by a person or by a company to have exclusive rights to use its own plans, ideas, or other intangible assets without the worry of competition, at least for a specific period of time. These rights can include copyrights, patents, trademarks, and trade secrets. These rights may be enforced by a court via a lawsuit. The reasoning for intellectual property is to encourage innovation without the fear that a competitor will steal the idea and / or take the credit for it.


Plagiarism as copying another's work or borrowing someone else's original ideas. But terms like "copying" and "borrowing" can disguise the seriousness of the offense:

  • to steal and pass off (the ideas or words of another) as one's own
  • to use (another's production) without crediting the source
  • to commit literary theft
  • to present as new and original an idea or product derived from an existing source
In other words, plagiarism is an act of fraud. It involves both stealing someone else's work and lying about it afterward

Digital rights management
DRM – A scheme that controls access to copyrighted material using technological means. It means applying technology on copyrighted material in such a way that it can be used or it remain in read only mode but further production/copying is restricted.

                                                        Licensing
 A software license is a document that provides legally binding guidelines to the person who holds it for the use and distribution of software. It typically provide end users with the right to make one or more copies of the software without violating copyrights. It also defines the responsibilities of the parties entering into the license agreement and may impose restrictions on how the software can be used. Software licensing terms and conditions usually include fair use of the software, the limitations of liability, warranties and disclaimers and protections.

Licensing (Creative Commons )
Creative Commons (CC) is an internationally active non-profit organization to provide free licenses for creators to use it when making their work available to the public in advance under certain conditions.

Licensing (GPL)
GPL - General Public License( GPL), is the most commonly used free software license, written by Richard Stallman in 1989 of Free Software Foundation for Project. This license allows software to be freely used(means freedom for use,not price wise free), modified, and redistributed by anyone. WordPress is also an example of software released under the GPL license, that’s why it can be used, modified, and extended by anyone.

Licensing (Apache)
The Apache License is a free and open source software (FOSS) licensing agreement from the Apache Software Foundation (ASF). Beginning in 1995, the Apache Group (later the Apache Software Foundation) Their initial license was essentially the same as the old BSD license. Apache did likewise and created the Apache License v1.1 - a slight variation on the modified BSD license. In 2004 Apache decided to depart from the BSD model a little more radically, and produced the Apache License v2.  ( Berkeley Software Distribution (BSD), )

                                               Open Source 
open source means any program whose source code is made available publically for use or modification as users or other developers see fit. Open source software is usually made freely available.

                                               Open data
Open data is data which can be accessed, used and shared by any one to bring about social, economic and environmental benefits. Open data becomes usable when made available in a common , machine-readable format.

                                            Privacy 
Privacy is the aspect of information technology which deals with the ability of an organization or individual to determine what data in a computer system can be shared with third parties.

privacy laws
 privacy law - Regulations that protects a person's/organization’s data private and governs collection, storage, and release of his or her financial, medical, and other personal information to third party. Classification of privacy laws • General privacy laws that have an overall bearing on the personal information of individuals • Specific privacy laws that are designed to regulate specific types of information. E.g Communication privacy laws, Financial privacy laws,Health privacy laws,Information privacy laws ,Online privacy laws ,Privacy in one’s home.

     Fraud
 Computer fraud is using a computer and/or internet to take or alter electronic data, or to gain unlawful use of a computer/internet. Illegal computer activities include phishing, social engineering, viruses.

Cyber crime 
 Any crime that involves a computer and a network is called a “Computer Crime” or “Cyber Crime. Or in other term ,it is a crime in which a computer is the object of the crime (hacking, phishing, spamming) or is used as a tool to commit an offense (child pornography, hate crimes).

Cyber crime (Phishing)
Phishing is a cyber attack that uses disguised email as a weapon.The attackers masquerade as a trusted entity of some kind, The goal is to trick the email recipient into believing that the message is something they want or need — recipient fills/send sensitive information like account no, username ,password etc. ,then attacker use these.

Cyber crime (Illegal downloading)
Illegal downloading is obtaining files or computer resources that w do not have the right to use from the Internet. Copyright laws prohibit Internet users from obtaining copies of media that we do not legally purchase. These laws exist to prevent digital piracy, much of which is generally conducted through Internet file sharing.

Cyber crime(Child pornography) 
Child pornography is considered to be any depiction of a minor or an individual who appears to be a minor who is engaged in sexual or sexually related conduct. This includes pictures, videos, and computer-generated content. Even altering an image or video so that it appears to be a minor can be considered child pornography.

Cyber crime (Scams)
Scams:  With the growth in online services and internet use, there are many opportunities for criminals to commit scams and fraud. These are dishonest schemes that seek to take advantage of unsuspecting people to gain a benefit (such as money, or access to personal details). These are often contained in spam and phishing messages.

Cyber crime (Cyber forensics)
Cyber forensics is a way or an electronic discovery technique which is used to determine and reveal technical criminal evidence. Various capabilities of cyber forensics

IT Act 2000
The Information Technology Act, 2000 provides legal recognition to the transaction done via an electronic exchange of data and other electronic means of communication or electronic commerce transactions.Some of sections under it act 2000 are given below.
SECTI ON , OFFENCE  , PENALTY

67A                 
Publishing images containing sexual acts
Imprisonment up to seven years, or/and with fine up to Rs. 1,000,000

 67B 
Publishing child porn or predating children online
Imprisonment up to five years, or/and with fine up to Rs.1,000,000 on first conviction. Imprisonment up to seven years, or/and with fine up to Rs.1,000,000 on second conviction. 

67C
Failure to maintain records 
Imprisonment up to three years, or/and with fine.

Technology and society:
Technology affects the way individuals communicate,learn,andthink.Technology has both positive and negative affects on society including the possible improvement or declination of society. Society is defined as,"the sum of social relationships among humanbeings "and technology is defined as, "the body of knowledge available to acivilization that is of use in fashioning implements, practicing manual arts and skills, and extracting or collecting materials. "Technology shapes our society and has both positive and negative affects".

Societal issues and cultural changes induced by technology
Cultural changes–
Technology has completely changed our culture. From our
values, To our means of communication. Now, Many people
have trouble having a face to face conversation, Skype does
not count. When people spend time with friends, Its on their
phones, Tablets, Or computers. Also, Now people judge
others by how techy their car is, Or if they have the newest
iPhone or Tablet Most people want to put their headphones in
and listen to music rather than listening to another person.
Video games isolate all things from the world. Most people
prefer technology today, Just because that is all they know.
Today it’s all about touch screen cell phones. Technology just
isolates people from reality. People now a days don’t know
how to communicate in real world situations like personal
relationships, Problem solving and exhibiting adult behaviors.

E-waste Management:
Whenever an electronic device covers up its working life,or becomes non-usable due to technological advancements or becomes non-functional, it is not used any more and comes under the category of e-waste or electronic waste. As the technology is changing day by day, more and more electronic devices are becoming non-functional and turning in to e-waste. Managing such non-functional electronic devices is termed as e-waste management.

E-waste Management:(Proper disposal of used electronic gadgets)
E-waste is a growing problem for us in India. As an 132cr
strong economy, we produce e- waste in large quantities.
It is very important to dispose off waste in a pragmatic
manner.
Ways to dispose off e-waste:
1. Give Back to Your Electronic Companies and Drop Off
Points
2. Visit Civic Institutions
3. Donating Your Outdated Technology
4. Sell Off Your Outdated Technology
5. Give Your Electronic Waste to a Certified E-Waste
Recycler

Identity theft:

Identity theft occurs when some one uses our identity or personal information—such as our name, our license,or our Unique ID number—without our permission to commit a crime or fraud.

Unique IDs and biometrics
A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity with in a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.

Biometrics is the science of analyzing physical or behavioral characteristics specific to each individual in order to be able to authenticate their identity.

Gender and disability issues while teaching/using computers

Disability Issues
1.Unavailability of teaching materials/aids
2.Lack of special needs teachers
3.Lack of supporting curriculum
Possible Solution
•Enough teaching aids must be prepared for specially abled students
•Must employ special needs teachers
•Curriculum should be designed with students with specially abled students in mind.