Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved All Assignments! #35

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions AI answers
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
ADD Artificial Intelligence answers here.
ANSWERS OF PYTHON:
# 1
def is_prime(num):
"""Check if the input number is prime."""
if num <= 1:
return False
elif num == 2:
return True
else:
for i in range(2, int(num ** 0.5) + 1
):
if num % i == 0:
return False
return True

#2

def reverse_string(input_string):
return input_string[::-1]

#3
import pandas as pd
data = {'Name': ['Alice', 'Bob'],
'Age': [25, 30]}
df = pd.DataFrame(data)
print(df)

#4
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(matrix)

#5
dictionary = {'zebra': 1, 'apple': 2, 'banana': 3, 'mango': 4}
print(alphabetical_keys(dictionary))

def alphabetical_keys(dictionary):
keys = list(dictionary.keys())
keys.sort()
return keys

#6
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)

print(factorial(5))

#7
arr = np.array([1, 2, 3, 4, 5])
mean = np.mean(arr)
std_dev = np.std(arr)
print("Mean is :", mean)
print("Standard Deviation is :", std_dev)

#8
import pandas as pd
df = pd.DataFrame(df_data, columns=['A', 'B'])
sum_of_A = df.loc[df['B'] > 10, 'A'].sum()
print(sum_of_A)
105 changes: 105 additions & 0 deletions CP answers
Original file line number Diff line number Diff line change
@@ -1 +1,106 @@
ADD Competitive Programming answers here.
Question 1)
int A=5,B=7;
int multiplyAB = A * B ;
System.out.println("The product of "+A+" and "+B+ " is :
"+multiplyAB);
Question 2)
int num = 9;
if (num%2==0) {
System.out.println(num +" is Even Number");
}
else{
System.out.println(num +" is Odd Number");

}
Question 3)
int n = 6;
long fact = 1;
for (int i = 1; i <=n; i++) {
fact =fact*i;
}
System.out.println("Factorial of"+n+"is="+fact);
}
Question 3)
int n = 6;
long fact = 1;
for (int i = 1; i <=n; i++) {
fact =fact*i;
}
System.out.println("Factorial of"+n+"is="+fact);
}
Question 4)
String str ="MBM University";
int count = 0;
char ch;
for (int i = 0; i <str.length(); i++) {
ch = str.charAt(i);
if (ch == 'a'|| ch == 'e'|| ch== 'i' || ch == 'o'|| ch == 'u')
count++;
}
System.out.println("Number of Vowels in String are:"+count);
Question 5)
int arr[] = {34,89,65,39,7,45};
int max=arr[0];
for(int i=1;i<arr.length;i++){
if(max<arr[i])
max=arr[i];
}System.out.println("Maximum element in Array is : "+max);
Question 6)
int min=arr[0];
for(int i=1;i<arr.length;i++){
if(min>arr[i])
min=arr[i];
}System.out.println("Minimum element in Array is: "+min);
Question 7)
int A=10;
int B=5;
System.out.println("Before Swapping");
System.out.println("A = " + A);
System.out.println("B = " + B);
System.out.println("After Swapping");
int temp = A;
A = B;
B = temp;
System.out.println("A = " + A);
System.out.println("B = " + B);
Question 8)
int yr=2000;
if((yr%4==0 && yr%100!=0) ||
(yr%400==0))
System.out.println(yr+" is Leap Year");
else{
System.out.println(yr+" is Not Leap Year");
}
Question 9)
String s="Helloooo";
char c[]=s.toCharArray();
int n=c.length;
for(int i=0,j=n-1;i<j;i
,j--){
char temp=c[i];
c[i]=c[j];
c[j]=temp;
}
Question 10)
int max_of_three=Math.max(10, Math.max(20 ,30));
System.out.println("Maximum number among the three numbers is :"+ max_
of_three);
}
Answers of MCQ
Q1)
D) O(1)
Q2)
A) Queue
Q3)
B) Exit the loop
Q4)
A) Must be sorted
Q5)
B) The number of operations it performs






47 changes: 47 additions & 0 deletions Web Devlopment answers
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
ADD Web Development Answers here.
ANSWERS OF HTML:
<!-- Q1 -->
<label for="checkbox">checkbox</label>
<input type="checkbox" id="checkbox" name="checkbox">
<!-- Q2 -->
<p>
<pre>Text in a pre element<br>
is displayed in a fixed-width<br>
font, and it preserves<br>
both spaces and<br>
line breaks</pre><br>
</p>
<!-- Q3 -->
<a target="_blank" href="#">New Tab Link</a>.

<!-- Q4 -->
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<input type="submit" value="Submit">
</form>
<!-- Q5 -->
<ul>
<li>coffee</li>
<li>tea</li>
<li>milk</li>
</ul>
ANSWERS OF JAVASCRIPT:
// 1.
let x = document.getElementById("demo");
// 2.
let btn = document.querySelector('button');
btn.addEventListener('click', function(){
alert("You clicked me!");
});
// 3.
setTimeout(function() {console.log("Hello")}, 2000);
//4.
2
4
3
1

// 5.
for (let i in myObject) {
console.log(Key: ${i} Value: ${myObject[i]});
}