0% found this document useful (0 votes)
3 views6 pages

Print Asap

The document contains a series of Python code snippets that address various programming tasks, including counting vowels and consonants in a string, checking for palindromes, finding the smallest and largest elements in a list, separating elements by odd and even indices, searching for an element in a list, and collecting student details with their marks. Each task is presented as a question followed by the corresponding code implementation. The code snippets demonstrate basic programming concepts such as loops, conditionals, and data structures.

Uploaded by

botzee88
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)
3 views6 pages

Print Asap

The document contains a series of Python code snippets that address various programming tasks, including counting vowels and consonants in a string, checking for palindromes, finding the smallest and largest elements in a list, separating elements by odd and even indices, searching for an element in a list, and collecting student details with their marks. Each task is presented as a question followed by the corresponding code implementation. The code snippets demonstrate basic programming concepts such as loops, conditionals, and data structures.

Uploaded by

botzee88
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
You are on page 1/ 6

Question number 9

# Input string from user

Input_str = input(“Type the string: “)

Vowel_count = 0

Consonant_count = 0

Vowel = set(“aeiouAEIOU”).

# Counting vowels and consonants

For alphabet in input_str:

If alphabet in vowel:

Vowel_count += 1

Elif alphabet == chr(32):

Consonant_count = consonant_count

Else:

Consonant_count += 1

Print(f”Number of Vowels in ‘{input_str}’: {vowel_count}”)

Print(f”Number of Consonants in ‘{input_str}’: {consonant_count}”)

# Counting uppercase and lowercase letters

Uppercase_count = 0

Lowercase_count = 0

For elem in input_str:

If elem.isupper():

Uppercase_count += 1

Elif elem.islower():

Lowercase_count += 1

Print(f”Number of UPPER Case letters in ‘{input_str}’: {uppercase_count}”)


Print(f”Number of lower case letters in ‘{input_str}’: {lowercase_count}”)

QUESTION NUMBER 10

# Input string from user

Input_str = input(“Enter a string: “)

Reversed_str = “”

# Reverse the string

For element in input_str[::-1]:

Reversed_str += element

# Check if the input string is a palindrome

If input_str == reversed_str:

Print(f”{input_str} is a Palindrome string”)

Else:

Print(f”{input_str} is NOT a Palindrome string”)

QUESTION NUMBER 11

List1 = []

# Input number of elements to put in list

Num = int(input(“Enter number of elements in the list: “))

# Iterating till num to append elements in list


For I in range(1, num + 1):

Element = int(input(“Enter element: “))

List1.append(element)

# Print the smallest element

Print(“Smallest element in List1 is:”, min(list1))

QUESTION NUMBER 12

# Entering 5 elements in the list

Mylist = []

Print(“Enter 5 elements for the list:”)

For I in range(5):

Value = int(input())

Mylist.append(value)

# Printing original list

Print(“The original list: “ + str(mylist))

#Separating odd and even index elements

Odd_i = []

Even_i = []

For I in range(len(mylist)):

If I % 2:

Even_i.append(mylist[i])

Else:

Odd_i.append(mylist[i])
Result = odd_i + even_i

# Print result

Print(“Separated odd and even index list: “ + str(result))

QUESTION NUMBER 13

# Entering 5 elements in the list

Mylist = []

Print(“Enter 5 elements for the list:”)

For I in range(5):

Value = int(input())

Mylist.append(value)

#Asking for the element to search

Element = int(input(“Enter an element to search: “))

# Searching for the element in the list

For I in range(5):

If element == mylist[i]:

Print(“\nElement found at Index:”, i)

Print(“Element found at Position:”, I + 1)

QUESTION NUMBER 14
# Create empty list

Mylist = []

Number = int(input(‘How many elements to put in the list: ‘))

# Iterating to append elements in the list

For n in range(number):

Element = int(input(‘Enter element: ‘))

Mylist.append(element)

# Print the maximum and minimum elements in the list

Print(“Maximum element in the list is:”, max(mylist))

Print(“Minimum element in the list is:”, min(mylist))

QUESTION NUMBER 15

# Enter number of students

No_of_std = int(input(“Enter number of students: “))

Result = {}

# Enter details for each student

For I in range(no_of_std):

Print(“Enter Details of student No.”, I + 1)

Roll_no = int(input(“Roll No: “))

Std_name = input(“Student Name: “)

Marks = int(input(“Marks: “))

Result[roll_no] = [std_name, marks]


# Print the result dictionary

Print(result)

# Display names of students who have got marks more than 75

Print(“Student(s) who scored more than 75 marks:”)

For student in result:

If result[student][1] > 75:

Print(result[student][0])

You might also like