0% found this document useful (0 votes)
4 views4 pages

Python and Java Coding Exercises

The document outlines a series of programming exercises and tasks across various topics, including basic loops, arrays, strings, and logical coding questions. It provides specific instructions for tasks such as printing numbers, manipulating arrays, and working with strings, as well as implementing algorithms for prime numbers and Fibonacci series. Additionally, it includes pattern printing exercises to enhance coding skills.

Uploaded by

geethakuruva2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Python and Java Coding Exercises

The document outlines a series of programming exercises and tasks across various topics, including basic loops, arrays, strings, and logical coding questions. It provides specific instructions for tasks such as printing numbers, manipulating arrays, and working with strings, as well as implementing algorithms for prime numbers and Fibonacci series. Additionally, it includes pattern printing exercises to enhance coding skills.

Uploaded by

geethakuruva2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Foundation level

1.​ Print 1,2,3,..99,100 using for loop.


2.​ Print 0,2,4,6,..98,100 using for loop.
3.​ Print take a no find even or odd
4.​ swap with temp and without temp
5.​ print 1-10 first line, 2-20 second line etc. up to 100.
6.​ read a char, find vowel are not with if else, with switch also.
7.​ read age, find if a person is eligible for voting.
Arrays / list basics to moderate level:
8.​ take an array / list of 10 random numbers. print elements in reverse order. python students using
for loop with ranges. java people should use a for loop.
9.​ take an array / list of 10 random numbers. print alternate elements 0th, 2nd, 4th etc. Python
students use for loop with ranges. java should use a for loop.
10.​ take array 1/list1 with some random numbers. copy the elements of that array / list into a second
array2 / list2.

11.​ take array 1/list1 with some random numbers. copy the elements of that array / list into a second
array2 / list2 in reverse order
12.​ take an array / list of 10 random numbers. write logic to count how many even nos are there and
how many odd numbers are there.

13.​ take an array / list of 10 random numbers. find big in that array / list. don't use the max()
function.
14.​ take an array / list of 10 random numbers. find even big and odd big in that array / list. don't use
the max() function.
15.​ take an array / list of 10 random numbers. copy even numbers into array2/list2. copy odd
numbers into array3/list3. don't use copy() or other copying methods.
16.​ take arr1/list1, arr2/list2 with some random numbers. take an empty arr3/list3 of relevant size.
copy first arr1/list1 into arr3/list3. copy the next arr2/list2 elements into arr3/list3.
17.​ take an arr / list with some numbers. print even nos present in the even positions.
18.​ take 2 arrays / lists with some numbers. add both arrays / list into third array / list
Strings basics to moderate level
19.​ take a string, reverse the string and print it. check if it is a palindrome string or not. python
students should not use [::-1]
20.​ take a string. count how many vowels are there in the string. you have considered both small
letters and capital letters.
21.​ take a string. replace vowels in the string with letter z. After that print the string.
22.​ take a string, count how many words are there. assume that there are no extra spaces in the
string and there are no spaces at the beginning and and the end.
23.​ take 2 strings. find those 2 strings are anagrams. if 2 strings are of same length, and made up of
same letters with dif combinations then it is anagram.
24.​ take a string. write logic to count how many no of times each letter is repeating in that string.
[letter occurrences]
25.​ take a statement. print words in the reverse order. eg: "palle tech pvt ltd" . output : ltd pvt tech
palle. student can use split() function
26.​ take a statement. print words in the reverse order. eg: "palle tech pvt ltd" . output : ellap hcet tvp
dtl. student can use split() function
27.​ take a string, print unique letters present in the string.
28.​ take a string, print duplicate letters present in the string.
General logical coding questions
29.​ prime number
30.​ fibonacci series
31.​ factorial of a number
32.​ palindrome number
33.​ armstrong number
Others
34.​ sort the array / list, without using sort() function.
35.​ take an array / list with some numbers. find the second biggest number with only one for loop.
don't sort. don't use max()
36.​ take an array / list with random 0's 1's. move 0's to left and 1's to right. don't sort.
37.​ find the factorial of a number with recursion.
38.​ take a string. find the largest substring with unique letters. if any letter repeats you have to stop
there.
39.​ search for an element in the array / list. print the position. if element is not found, print -1.
Patterns (40 to 50)

Write logics to print below patterns


*
**
***
****
*
**
***
****
*****
****
***
**
*
*****
****
***
**
*

1
22
333
4444

1
12
123
1234

a
ab
abc
abcd

a
bb
ccc
dddd

1
23
456
78910

*
***
*****
*******
*********

*******
*****
***
*

You might also like