Monday 28 June 2021

Python program to Expand Alphabet

Expand Alphabets

This program takes a string Str as input. The input string contains a sequence of an integer followed by an alphabet. The output must print the alphabets as many times as the related integer on its left.

Input

1a2b

Output

abb

Input 

a3r

In this case, the output will be rrr.

If only the input is given in the correct format, the output will be displayed. If the input is incorrect then no output is produced.

Incorrect Input

a3

PROGRAM

Str = input("Enter the input string:")

num = ""

l=len(Str)

i=0

while (i < l):

    if (Str[i] >= '0' and Str[i] <= '9'):

        while (i < l and Str[i] >= '0' and Str[i] <= '9' ):

            num=num+Str[i]

            i=i+1

        num=int(num)

        if (i < l):

            while (num > 0):

                print(Str[i],end="")

                num=num-1

    i=i+1

    num=""


OUTPUT

Enter the input string:100q2w

qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqww


Enter the input string:a3r

rrr

Saturday 26 June 2021

Counting alphabets and lines in a sentence

This program reads the contents of the file which is given as input. Then counts the number of lines in each sentence and also the alphabets in each sentence. Each English sentence ends with a period(.). 

For example, if the file contains 

This program reads the contents of the file which is given as input. Then counts the number of lines in each sentence and also the alphabets in each sentence. Each English sentence ends with a period. 


Here the first sentence ends in the first line so line count is 1

The second sentence starts in first line and ends in second line, so the line count is 2. 

The third sentence ends in second line, so the line count is 1.


Program

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>


int main()

{

    FILE *f1;

    char fname[20],c,pc;

    int lc=0,ac=0,sc=0,i,flag=0;

    int Line[50],Alpha[50];


    printf("Enter the file name\n");

    gets(fname);

    

    f1 = fopen(fname, "r");

    if (f1==NULL)

    {

printf("File open error");

getch();

exit(0);

    }

    printf("\n\nFile %s contents\n\n",fname);

    while((c=fgetc(f1))!=EOF)

        putchar(c);

    fclose(f1);

    printf("\n\n");

    

    f1=fopen(fname,"r");

    while(!feof(f1))

    {

c=fgetc(f1);

if (c=='\n' && pc !='.')

  ++lc;

if ((c>='a' && c<='z') || (c>='A' && c<='Z'))

  ++ac;

if (c=='.')

{

  ++sc;

  ++lc;

  Line[sc]=lc;

  Alpha[sc]=ac;

  lc=0;

  ac=0;

}

pc=c;

    }

    fclose(f1);

    for(i=1;i<=sc;i++)

    {

          printf("\nThe number of lines and alphabets in sentence %d is %d, %d", i, Line[i],                Alpha[i]);

     } 

   getch();

   return 0;

}


OUTPUT

Enter the file name

test.txt

File test.txt contents


Welcome to the world of programming. It is

fun to learn programming through blogs and

online tutorials.

Happy learning.


The number of lines and alphabets in sentence 1 is 1, 30

The number of lines and alphabets in sentence 2 is 3, 55

The number of lines and alphabets in sentence 3 is 1, 13


Friday 18 June 2021

Shell script to work with command line arguments

In this shell script, we will learn the use of the commands to display the first command-line argument and the total number of command-line arguments in a shell script.

$0 - always refers to the shell program being executed

$# - returns the total number of arguments given in the command line

$@ - returns the entire list of the arguments in the command line

$* - returns the entire list of arguments in the command line double quoted

$1, $2,.............., $9 -  returns the arguments in the position specified


PROGRAM

#Shell script to work with command line arguments
echo -e "\nThe first argument in a command line refers to the program name"
echo -e "The first argument here is $0 \n"
echo "The list of arguments given in the command line are"
echo -e "$* \n"
echo "The total number of command line arguments is " : $#



OUTPUT

$ sh clarg.sh hello welcome to unix programming


The first argument in a command line refers to the program name

The first argument here is clarg.sh


The list of arguments given in the command line are

hello welcome to unix programming


The total number of command line arguments is  : 5

Thursday 17 June 2021

MCQs in RDBMS

Relational Database Management System is a core subject taught in almost all computer science curriculum. The following 30 multiple-choice questions will help you to check your basic knowledge in this subject. It will also be a useful resource for the teachers to conduct quiz tests in RDBMS.


Choose the best answer (Multiple choice questions)

 

1. A relational database consists of a collection of ____________ .

A) Tables                     B) Fields                     C) Records                  D) Keys

2. A ________ in a table represents a relationship among a set of values.

A) Column                  B) Key                         C) Row                       D) Entry

3. The term attribute refers to a ___________ of a table.

A) Record                   B) Column                  C) Tuple                      D) Key

4. For each attribute in a relation, there is a set of permitted values, called the ________ of that attribute.

A) Domain                  B) Relation                  C) Set                          D) Schema

5. The result of the operation which contains all pairs of tuples from the two relations, regardless of whether their attribute values match.

A) Join                        B) Cartesian product   C) Intersection             D) Set difference

6. The _______operation performs a set union of two “similarly structured” tables

A) Union                     B) Join                         C) Product                  D) Intersect

7. Using which language can a user request information from a database?

A) Query                     B) Relational               C) Structural               D) Compiler

8. Student (ID, name, dept name, tot_cred) In this relation which attributes form the primary key?

A)  name                     B) dept                          C) tot_cred                  D) ID

9.  Which one of the following is a procedural language?

A) Domain relational calculus                  B) Tuple relational calculus

C) Relational algebra                                 D) Query language

10. The_____ operation allows the combining of two relations by merging pairs of tuples, one from each relation, into a single tuple.

A) Select         B) Join                         C) Union                     D) Intersection

11. The most commonly used operation in relational algebra for projecting a set of tuple from a relation          is _____________ .

A) Join             B) Projection               C) Select                      D) Union

12. The _________ provides a set of operations that take one or more relations as input and return a              relation as an output

A) Schematic representation               B) Relational algebra     

C) Scheme diagram                             D) Relation flow

13. A relation schema consists of a list of attributes and their corresponding _________ .

A)    Variables               B) Instances                C) Domains                 D) Tuples

14. Which one of the following is used to define the structure of the relation, deleting relations and    relating schema

A) DML(Data Manipulation Language)         B) DDL(Data Definition Language)

C)  Query                                                        D) Relational Schema

15. Select * from employee. What type of statement is this?

A) DML                      B) DDL                       C) View          D) Integrity constraint

16. The basic data type char(n) is a _____ length character string and varchar(n) is _____ length                     character.

A) Fixed, equal           B) Equal, variable       C) Fixed, variable       D) Variable, equal

17. To remove a relation from an SQL database, we use the ______ command.

A) Delete                    B) Purge                      C) Remove                  D) Drop table

18. Updates that violate __________ are not allowed.

A) Integrity constraints                       B) Transaction control

C) Authorization                                 D) DDL constraints

19. In SQL the spaces at the end of the string are removed by _______ function.

            A) Upper                     B) String                      C) Trim                    D) Lower

 20. Which one of the following sort rows in SQL?

            A) SORTBY               B) ALIGNBY             C) ORDERBY           D) GROUPBY

21. The _______ menu command in SQL * PLUS is used to store the query results in a file.

            A) Save                       B) Spool                      C) Run                      D)  Screen Buffer

22. SQL * PLUS is a ___________________.

            A) editor                     B) query language       C) command-line tool D)  interpreter

23. Which of the following is used to store movie and image files?

A) CLOB                      B) BLOB                       C) Binary                    D) Image

24. To include integrity constraint in an existing relation use :

A) Create table            B) Modify table          C) Alter table              D) Drop table

25.  Which of the following is used to define code that is executed/fired when certain actions or event         occur?

A) Replace                  B) Keyword                C) Trigger                    D) Cursor

26. Which of the following is used to input the entry and give the result in a variable in a procedure?

A) Put and get                        B) Get and put                        C) Out and In             D) In and out

27. The default extension for an Oracle SQL*Plus file is:

A) .txt                         B) .pls                          C) .ora                         D) .sql

28. The variables in the triggers are declared using

A) –                             B) @                           C) /                              d) &

29. Which of the following is not a PL/SQL unit?

A) Table                      B) Type                       C) Trigger                    D) Package

30. Which of the following statements can be used to terminate a PL/SQL loop?

A) GOTO                    B) EXIT WHEN         C) CONTINUE WHEN         D) BREAK

ANSWERS

1.      A               2. C                 3. B                 4.  A                5. B                 6. A    

7.  A                8. D                 9. C                 10. B               11. C               12. B              

13. C               14. B               15. A               16. C               17.  D              18. A  

19. C               20. C               21.  B              22. C               23. B               24. C              

25. C               26. D               27. D               28. B               29. A               30. B

Data Science in Tamil

You can learn Python and the necessary tools to become a Data Scientist by joining this telegram channel. 


https://t.me/joinchat/HJ27sc61uqk5MDEx

Daily online class is conducted online from 9PM and all the class materials are shared through Google classroom. The classes are very interactive and very useful. Everything is given free of cost.

இந்த குழுவில் என்ன கற்று தர போகிறோம்?

1. Python 

2. NumPy 

 3.Pandas

4. MatPlotLib

5. SciPy 

6. Scikit-learn

7. TensorFlow 

எந்த வகையில் உங்களுக்கு பயன் தரும்?

1.நீங்கள் Data scientist ஆகலாம்.

2. Python programmer ஆகலாம். Games, Websites, web applications தயாரிக்கும் கம்பெனிகளில் வேலைக்கு சேரலாம்.

3. கணிப்பொறி சிறப்பு அலுவலர் (Specialised IT officer) ஆகலாம்.


குழுவில் நண்பர்களை இணைத்து பயன் பெற செய்யுங்கள். 👇


https://t.me/joinchat/HJ27sc61uqk5MDEx

Tuesday 15 June 2021

Artificial Intelligence MCQ

 Multiple Choice Questions in Artificial Intelligence

Artificial Intelligence has taken up the Software Industry to a greater height with a lot of research being devoted to Artificial Intelligence techniques and Machine Learning algorithms. One who is interested to test his knowledge can do so by answering as many quizzes or multiple choice questions in Artificial Intelligence. This post will help the users to test their knowledge in Artificial Intelligence basics.


Choose the best answer (Multiple choice questions)

1.      Artificial Intelligence is about_____.

A)       Playing a game on Computer                             

B)    Making a machine Intelligent

C)    Programming on Machine with your Own Intelligence

D)    Putting your intelligence in Machine

 

2.      Who is known as the -Father of AI"?

A)    Fisher Ada                        B) Alan Turing            C) John McCarthy      D) Allen Newell

 

3.      Which of the following is not the type of AI?

A) Reactive machines             B) Unlimited memory            

C) Theory of mind                  D) Self-awareness

 

4.      What is the term used for describing the judgmental or common sense part of problem-solving?

A)    Heuristic                B) Critical       C) Value based           D) Analytical

 

5.      Among the given options, which search algorithm requires less memory?

A)    Optimal Search                             B) Depth First Search

C)  Breadth-First Search                     D) Linear Search

 

6.      The available ways to solve a problem of state-space-search.

A)    1                B) 2                 C) 3                 4

 

7.      Which of the given language is not commonly used for AI?

A)    LISP                      B) PROLOG               C) Python                    D) Perl


8. A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence is known as the___.

A) Boolean Algebra    B) Turing Test             C) Logarithm              D) Algorithm


9. Which algorithm is used in the Game tree to make decisions of Win/Lose?

A) Heuristic Search Algorithm                       B) DFS/BFS algorithm

C)  Greedy Search Algorithm                         D) Min/Max algorithm


10. Which term describes the common-sense of the judgmental part of problem-solving?

A)  Values-based         B) Critical                   C) Analytical               D) Heuristic


11 A constraint satisfaction is a ______ procedure that operates in a space of constraint sets.

A)  Sorting                  B) Algorithmic            C) search         D) Algebraic


12. The need to backtrack in constraint satisfaction problem can be eliminated by ____________

A) Forward Searching                             

B) Constraint Propagation

C) Backtrack after a forward search  

D) Omitting the constraints and focusing only on goals


13. Among the given options, which is also known as inference rule?

A) Reference               B) Reform                   C) Resolution              D) Substitution


14. What is the name of the clause that is produced as a result of a resolution?

A) Contradiction         B) Parent         C) Disjunction             D) Resolvent


15. What is meant by factoring?

A) Removal of redundant variable                 B) Removal of redundant literal

C) Addition of redundant literal                    D) Addition of redundant variable


16.  A PROLOG program is composed of logical assertions called as _______________.

            A)  Horn clauses         B) Empty clauses        C) inference rules        D) productions


17.  Forward chaining systems are _______ and backward chaining systems are ________.

A) Goal-driven, goal-driven                           B) Goal-driven, data-driven

C) Data-driven, goal-driven                            D) Data-driven, data-driven


18. Which is mainly used for automated reasoning?

A)  Backward chaining                                   B) Forward chaining  

C) Logic programming                                    D) Parallel programming


19. Reasoning with some kind of measure of certainty is ___________.

            A) Statistical Reasoning                                 B) Monotonic reasoning        

            C) Non-monotonic reasoning                          D) Logical Reasoning


20. Default reasoning is another type of  _____________.

A) Analogical reasoning                                 B) Bitonic reasoning

C) Non-monotonic reasoning                         D) Monotonic reasoning


21. _________ is/are the well known Expert System/s for medical diagnosis systems.

A) MYCIN                 B) CADUCEUS         C) DENDRAL           D) SMH.PAL


22. The Bayesian network graph does not contain any cyclic graph. Hence, it is known as 

A) DCG                      B) DAG                      C) CAG                      D) SAG

 

23. A rudimentary form of learning, where the computed data is cached is called _______.

            A) Note learning                      B) Machine learning    

            C) Rote learning                      D) Stochastic learning


24.  Knowledge is generally acquired through ______________.

            A) Programming         B) Learning                 C) Inference                D) Experience


25.  The neural network that can be used as a content addressable memory is _______ networks.

            A) Hopfield          B) Perceptron              C) Bayesian       D) Backpropagation


26. The first program to support explanation and knowledge acquisition is ___________.

            A) MOLE              B) TEIRESIAS           C) XCON            D) PROSPECTOR


27.  The problem of translating text into speech is called as _____________.

            A) Speech Recognition                       B) Speech Production            

C) Speech translation                          D) Speech Transition


28. Initially, each expert system was created from scratch using ________ language.

            A) PROLOG              B) FORTRAN                        C) LISP                       D) Python


29.  Expert systems are  ___________ AI programs.

            A) weak                      B) complex                  C) strong                     D) simple


30. The first AI program to use learning techniques to construct the production rules automatically was _____________.

            A) MOLE              B) SALT              C) DENDRAL           D) META-DENDRAL

ANSWERS

        1)  B         2)  C         3)  B         4)  A                5)  B

        6)  B         7)  D         8)  B         9)  D         10) D

        11) C         12) A         13) C         14) D         15) B

        16) A         17) C         18) C         19) A         20) C

        21) A         22) B         23) C         24) D         25) A

        26) B         27) B         28) C         29) B         30) D


Big Data Analytics MCQ

After leaning the fundamentals of Big Data Analytics, students can test their knowledge by answering this multiple choice questions which covers a wide variety of topics in Big Data Analytics. Also this MCQ helps the teachers to set question papers on Big Data analytics.

Choose the best answer (Multiple choice questions)

1.  Which is not the characteristic of Big Data?

            A) Velocity               B) Viscosity              C) Variety                 D) Volume

2. The form of data that is structured but is not defined is

A) Processed           B) Semi-structured      C) Structured          D) Unstructured

3. Concerning the Forms of Big Data, which one of these is odd?

A) Structured              B) Unstructured          C) Processed        D) Semi-Structured

4. The most widely used Apache project for processing big data is

A) Apache Beam                                B) Apache Cassandra            

C) Apache Hadoop                             D) Apache Spark

5. The word 'Big data was coined by

A) Roger Mougalas     B) John Philips      C) Simon Woods        D) Martin Green

6. __________ data does not conform to any pre-defined data model.

A) Structured         B) Unstructured          C) Processed         D) Semi-Structured

7.  The examination of large amounts of data to see what patterns or other useful information can be found is known as what?

A) Big data tactics                                          B) Small data analysis            

C) Big data analytics                                      D) Small data tactics

8. Big data analysis does the following except?

A) Collects data                      B) Spreads data         

C) Organizes data                   D) Analyzes data

9. Which of the following is not an application for data science?

A) Recommendation Systems                        B) Image & Speech Recognition

C) Online Price Comparison                          D) Privacy Checker

10. Which of the following is not a major data analysis approach?

A) Data Mining                                   B) Predictive Intelligence

C) Business Intelligence                     D) Text Analytics

11. Which of the following is not a Benefit of Big Data Processing?

A) Businesses can utilize outside intelligence while taking decisions

B) Improved customer service

C) Better operational efficiency

D) Enhances data security and privacy

12. What is the work of Data Architect?

A) Utilize large data sets to gather information that meets their company's needs

B) Work with businesses to find the best usage of the information got from data

C) Build data solutions that are optimized for performance and design applications

D) All of the above 

13. “NoSQL” stands for ________________.

A) non SQL                B) native SQL             C) note SQL               D)  normal SQL

14.  NoSQL supports ____________.

A) Horizontal scaling, complex design, fine controlled availability

B) Horizontal scaling, simple design, fine controlled availability.

C) Vertical scaling, simple design, low control availability

D) Vertical scaling, simple design, fine controlled availability

15. ACID Properties refers to the _________________.

A) Atomicity Consistency Isolation Durability         

B) Active Consistency Isolation Durability

C) Atomicity Control Isolation Durability

D) Atomicity Consistency Idea Durability

16.  Which of the following are the simplest NoSQL databases?

A) Key-value              b) Wide-column          C) Document              D) Graph 

17. A collection and a document in MongoDB is equivalent to which of the SQL concepts?

A) Table and Row                              B) Table and Column             

C) Column and Row                           D) Database and Table 

18. Apache Cassandra is a massively scalable open source _______ database.

A) SQL                       B) NoSQL                  C) NewSQL                D) PL/SQL

19. What license is Hadoop distributed under?

A) Apache License 2.0                       B) Mozilla Public License

C) Shareware                                      D) Commercial 

20. What was Hadoop named after?

A) Creator Doug Cutting’s favorite circus act          

B) Cutting’s high school rock band

C) The toy elephant of Doug Cutting’s son              

D) A sound Cutting’s laptop made during Hadoop development 

21. What was Hadoop written in?

A) C                            B) C++                        C) Java                        D) JSP 

22. Which of the following platforms does Hadoop run on?

A) Bare metal              B) Debian                    C) Cross-platform       D) Unix-like 

23. A ________ node acts as the Slave and is responsible for executing a Task assigned to it by the    JobTracker.

A) MapReduce              B) Mapper             C) TaskTracker            D) JobTracker 

24. In Hadoop, the ___________ is considered as a single point of failure.

A) Data Node      B) NameNode      C) Secondary NameNode      D) Worker Node 

25. Input to the _______ is the sorted output of the Mappers.

A) Reducer                 B) Mapper                   C) Shuffle                   D) Cascader 

26. A ________ serves as the master and there is only one NameNode per cluster.

A) Data Node             B) NameNode             C) Data block              D) Replication 

27. Which of the following phases occur simultaneously?

A) Reduce and Sort                    B) Shuffle and Sort    

C) Shuffle and Map                    D) Shuffle and reduce 

28. HDFS works in a __________ fashion.

A) master-worker      B) master-slave         C) worker/slave         D) master/worker 

29. ________ is the slave/worker node and holds the user data in the form of Data Blocks.

A) DataNode              B) NameNode             C) Data block              D) Replication 

30. For YARN, the ___________ Manager UI provides host and port information.

A) Data Node             B) NameNode             C) Resource                D) Replication

 

ANSWERS

1. B                             2. B                             3. C                             4.  D                            5. A

6. B                             7. C                             8. B                             9. D                             10. B

11. D                           12. C                           13. A                           14.  B                          15. A

16. A                           17. A                           18. C                           19. A                           20. C

21. C                           22. C                           23. C                           24. B                           25. A

26. B                           27. B                          28. A                            29. A                           30. C