Skip to content

Instantly share code, notes, and snippets.

@ynonp
Last active July 27, 2023 12:24
Show Gist options
  • Save ynonp/b9be295ed4401c47997b54f7693e83d1 to your computer and use it in GitHub Desktop.
Save ynonp/b9be295ed4401c47997b54f7693e83d1 to your computer and use it in GitHub Desktop.
01-syntax

Python Syntax Exercises

  • Create a Python program that asks the user to tyep their age in years, and the program will convert and print their age in months.

  • Create a Python program that asks the user to type their age in months, and the program will convert and print their age in years.

  • Create a Python program to check the complexity of a password: It should ask the user for a word and verify the word contains a lowercase letter, an uppercase letter and a number.

  • Write a Python program that takes a number from the user and print the word "Boom" if that number divides by 7 or contains the digit 7

  • Write a Python program that takes 3 numbers from the user and prints out the largest one

  • Write a Python program that randomizes a number between 1 and 100. The user needs to guess the number in a loop. Every time a user tries a value the program responds with "too high" or "too low" accordingly.

Python Data Structures Exercises

  • Implement a "cows and bulls" game in Python: The computer selects a secret number of 5 different digits and the user needs to guess the value. After each guess the program prints how many digits were in their correct location, and how many digits were in the number but in different positions.

  • Write a program to find anagrams in lists of words. Two words are an anagram if they have the same letters (possibly in different order). The program should read an input file and print out the list of anagrams from the file, each group of anagrams is printed in its own line. For example given the following input file:

add
dad
help
more
rome

The program will print the output:

add dad
help
more rome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment