Python Programming Questions and Solutions
1) W.A.P to enter your school's name & print your school name up to 8th character n times.
```python
school_name = input("Enter your school's name: ")
n = int(input("Enter n: "))
print((school_name[:8] + '\n') * n)
```
2) W.A.P to calculate the total number of characters, digits, and spaces in a string.
```python
text = input("Enter a string: ")
characters = sum([Link]() for c in text)
digits = sum([Link]() for c in text)
spaces = sum([Link]() for c in text)
print(f"Characters: {characters}, Digits: {digits}, Spaces: {spaces}")
```
3) W.A.P to find whether two strings contain the same number of characters or not.
```python
str1 = input("Enter first string: ")
str2 = input("Enter second string: ")
print("Equal length" if len(str1) == len(str2) else "Not equal length")
```
4) W.A.P to print a string list in reverse order.
```python
string_list = input("Enter a list of strings separated by space: ").split()
print(list(reversed(string_list)))
```
5) W.A.P to take any message as input & print it without vowel characters.
```python
message = input("Enter a message: ")
vowels = "AEIOUaeiou"
print("".join(c for c in message if c not in vowels))
```
6) W.A.P to delete all the odd numbers & negative numbers in a numeric list.
```python
nums = list(map(int, input("Enter numbers separated by space: ").split()))
filtered_nums = [num for num in nums if num % 2 == 0 and num >= 0]
print(filtered_nums)
```
7) W.A.P to delete all duplicates from the given list.
```python
lst = [12, 12, 34, 34, 56, 11, 32, 32, 11, 10, 10]
lst = list(set(lst))
print(lst)
```
8) W.A.P to copy dictionary items.
```python
dict1 = {"a": 1, "b": 2, "c": 3}
dict2 = [Link]()
print(dict2)
```
9) W.A.P to change dictionary items.
```python
dictionary = {"name": "Alice", "age": 25}
dictionary["age"] = 30
print(dictionary)
```
10) W.A.P to convert the first letter of a sentence into capital.
```python
sentence = input("Enter a sentence: ")
print([Link]())
```
11) W.A.P to create a dictionary from a string (track the count of the letters).
```python
text = "w3resource"
letter_count = {char: [Link](char) for char in set(text)}
print(letter_count)
```
12) W.A.P to find the second highest value in a string.
```python
s = input("Enter a string with numbers: ")
numbers = sorted(set(int(c) for c in s if [Link]()), reverse=True)
print(numbers[1] if len(numbers) > 1 else "Not enough unique numbers")
```
13) W.A.P to read a list and remove duplicates, keeping only unique elements.
```python
lst = list(map(int, input("Enter numbers separated by space: ").split()))
unique_lst = list(set(lst))
print(unique_lst)
```
14) W.A.P to find the number of times an element occurs in a list.
```python
lst = list(map(int, input("Enter numbers separated by space: ").split()))
element = int(input("Enter element to count: "))
print([Link](element))
```