Python_Questions_Solutions
Python_Questions_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(c.isalpha() for c in text)
digits = sum(c.isdigit() for c in text)
spaces = sum(c.isspace() 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")
```
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)
```
11) W.A.P to create a dictionary from a string (track the count of the letters).
```python
text = "w3resource"
letter_count = {char: text.count(char) for char in set(text)}
print(letter_count)
```
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)
```